shellpuppet 0.5.2 → 0.5.3
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 +5 -5
- package/dist/agents/agy/nudge.js +58 -5
- package/dist/agents/agy/nudge.js.map +1 -1
- package/dist/agents/codex/index.js +1 -1
- package/dist/agents/codex/index.js.map +1 -1
- package/dist/agents/hermes/index.js +2 -2
- package/dist/agents/hermes/index.js.map +1 -1
- package/dist/agents/hermes/nudge.d.ts +1 -0
- package/dist/agents/hermes/nudge.js +5 -0
- package/dist/agents/hermes/nudge.js.map +1 -1
- package/dist/agents/types.d.ts +4 -0
- package/dist/cli/index.js +24 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/client/http.d.ts +2 -2
- package/dist/client/http.js +1 -1
- package/dist/client/http.js.map +1 -1
- package/dist/core/dialogs.d.ts +4 -1
- package/dist/core/dialogs.js +25 -5
- package/dist/core/dialogs.js.map +1 -1
- package/dist/core/mailbox.d.ts +8 -4
- package/dist/core/mailbox.js +22 -5
- package/dist/core/mailbox.js.map +1 -1
- package/dist/core/manager.d.ts +1 -0
- package/dist/core/manager.js +5 -1
- package/dist/core/manager.js.map +1 -1
- package/dist/core/policy.d.ts +5 -3
- package/dist/core/policy.js +25 -23
- package/dist/core/policy.js.map +1 -1
- package/dist/core/readingContext.d.ts +9 -0
- package/dist/core/readingContext.js +4 -0
- package/dist/core/readingContext.js.map +1 -0
- package/dist/core/reasoning.d.ts +2 -1
- package/dist/core/reasoning.js +33 -11
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/renderer.d.ts +1 -0
- package/dist/core/renderer.js +1 -0
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/session.d.ts +50 -32
- package/dist/core/session.js +332 -162
- package/dist/core/session.js.map +1 -1
- package/dist/daemon/config.d.ts +11 -1
- package/dist/daemon/config.js +42 -20
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/configReload.d.ts +55 -0
- package/dist/daemon/configReload.js +284 -0
- package/dist/daemon/configReload.js.map +1 -0
- package/dist/daemon/configWatcher.d.ts +55 -0
- package/dist/daemon/configWatcher.js +313 -0
- package/dist/daemon/configWatcher.js.map +1 -0
- package/dist/daemon/homeOwner.d.ts +2 -1
- package/dist/daemon/homeOwner.js +33 -8
- package/dist/daemon/homeOwner.js.map +1 -1
- package/dist/daemon/index.js +3 -50
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/launchProfiles.d.ts +5 -3
- package/dist/daemon/launchProfiles.js +12 -7
- package/dist/daemon/launchProfiles.js.map +1 -1
- package/dist/daemon/nudgeScheduler.d.ts +4 -4
- package/dist/daemon/nudgeScheduler.js +16 -15
- package/dist/daemon/nudgeScheduler.js.map +1 -1
- package/dist/daemon/paths.d.ts +22 -4
- package/dist/daemon/paths.js +126 -24
- package/dist/daemon/paths.js.map +1 -1
- package/dist/daemon/restartSource.d.ts +3 -3
- package/dist/daemon/restartSource.js +5 -4
- package/dist/daemon/restartSource.js.map +1 -1
- package/dist/daemon/schedules.d.ts +6 -5
- package/dist/daemon/schedules.js +15 -51
- package/dist/daemon/schedules.js.map +1 -1
- package/dist/daemon/server.d.ts +25 -17
- package/dist/daemon/server.js +547 -452
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/standaloneOptions.d.ts +4 -0
- package/dist/daemon/standaloneOptions.js +29 -0
- package/dist/daemon/standaloneOptions.js.map +1 -0
- package/dist/mcp/index.js +0 -4
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +0 -6
- package/dist/mcp/tools.js +90 -85
- package/dist/mcp/tools.js.map +1 -1
- package/dist/viewer/dashboard.css +21 -2
- package/dist/viewer/dashboard.js +44 -11
- package/dist/viewer/index.html +4 -3
- package/dist/viewer/pane.js +91 -395
- package/dist/viewer/viewer.css +23 -4
- package/dist/viewer/viewer.js +2 -0
- package/package.json +1 -1
package/dist/viewer/pane.js
CHANGED
|
@@ -43,12 +43,8 @@ window.ShellPuppetPane = (() => {
|
|
|
43
43
|
// A printable base (including space or a supplementary character) can carry combining marks.
|
|
44
44
|
const PRINTABLE_KEY = /^[\p{L}\p{M}\p{N}\p{P}\p{S}\p{Zs}]\p{M}*$/u;
|
|
45
45
|
const recentClipboardAge = (age, limit = CLIPBOARD_GESTURE_MS) => age >= 0 && age <= limit;
|
|
46
|
-
const NOTICE_HISTORY_MS = 10000;
|
|
47
|
-
const NOTICE_DECISION_MS = 1200;
|
|
48
|
-
const NOTICE_COVER_MARGIN_MS = 20;
|
|
49
|
-
const NOTICE_DELIVERY_GUARD_MS = 5;
|
|
50
|
-
const NOTICE_QUIET_MS = 1000;
|
|
51
46
|
const scaledEvents = new WeakSet();
|
|
47
|
+
const wheelViewportPositions = new WeakMap();
|
|
52
48
|
let scaledSelection = null;
|
|
53
49
|
const cellMetrics = new Map();
|
|
54
50
|
const fontListeners = new Set();
|
|
@@ -116,6 +112,7 @@ window.ShellPuppetPane = (() => {
|
|
|
116
112
|
passive = false,
|
|
117
113
|
redactedCapture = false,
|
|
118
114
|
elements = {},
|
|
115
|
+
promptChoice = { since: null, collapsed: false },
|
|
119
116
|
initialFontOverride = null,
|
|
120
117
|
onTitleChange = () => {},
|
|
121
118
|
onFontOverrideChange = () => {},
|
|
@@ -137,6 +134,7 @@ window.ShellPuppetPane = (() => {
|
|
|
137
134
|
let sessionEnded = false;
|
|
138
135
|
let inputFailed = false;
|
|
139
136
|
let promptWaiting = false;
|
|
137
|
+
let lastPromptContent = null;
|
|
140
138
|
let providerStall = null;
|
|
141
139
|
let gridCols = 0;
|
|
142
140
|
let gridRows = 0;
|
|
@@ -177,7 +175,6 @@ window.ShellPuppetPane = (() => {
|
|
|
177
175
|
const text = elements.banner.querySelector('.pane-banner-message') || elements.banner;
|
|
178
176
|
text.textContent = message;
|
|
179
177
|
elements.banner.hidden = false;
|
|
180
|
-
positionNotices();
|
|
181
178
|
};
|
|
182
179
|
|
|
183
180
|
const refreshTitle = () => {
|
|
@@ -189,7 +186,7 @@ window.ShellPuppetPane = (() => {
|
|
|
189
186
|
const showEnded = (exitCode) => {
|
|
190
187
|
if (sessionEnded) return;
|
|
191
188
|
sessionEnded = true;
|
|
192
|
-
|
|
189
|
+
if (promptWaiting) clearPromptAlert();
|
|
193
190
|
if (elements.readonly) elements.readonly.disabled = true;
|
|
194
191
|
const withCode = typeof exitCode === 'number';
|
|
195
192
|
if (elements.readonly) {
|
|
@@ -236,16 +233,74 @@ window.ShellPuppetPane = (() => {
|
|
|
236
233
|
refreshTitle();
|
|
237
234
|
};
|
|
238
235
|
|
|
239
|
-
const
|
|
236
|
+
const renderDisclosure = () => {
|
|
237
|
+
elements.promptToggle.setAttribute('aria-expanded', String(!promptChoice.collapsed));
|
|
238
|
+
elements.promptToggle.title = promptChoice.collapsed ? 'Expand waiting notice' : 'Collapse waiting notice';
|
|
239
|
+
elements.promptAlert.hidden = promptChoice.collapsed;
|
|
240
|
+
};
|
|
241
|
+
const togglePrompt = (event) => {
|
|
242
|
+
event.stopPropagation();
|
|
243
|
+
promptChoice.collapsed = !promptChoice.collapsed;
|
|
244
|
+
renderDisclosure();
|
|
245
|
+
};
|
|
246
|
+
const onPromptKeyDown = (event) => {
|
|
247
|
+
if (event.key !== 'Enter' || event.isComposing || event.defaultPrevented) return;
|
|
248
|
+
// A raw Enter can arrive without the keypress that generates a native click.
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
event.stopPropagation();
|
|
251
|
+
if (!event.repeat) event.currentTarget.click();
|
|
252
|
+
};
|
|
253
|
+
elements.promptToggle?.addEventListener('click', togglePrompt);
|
|
254
|
+
elements.promptToggle?.addEventListener('keydown', onPromptKeyDown);
|
|
255
|
+
|
|
256
|
+
// Passive notice text lets terminal clicks through. Route the wheel to
|
|
257
|
+
// the notice only over its visible, overflowing rectangle.
|
|
258
|
+
const notices = elements.notices;
|
|
259
|
+
const noticeViewport = notices?.parentElement;
|
|
260
|
+
// A capped stack can keep the same size while its contents grow or shrink.
|
|
261
|
+
// Observe both so only an overflowing touch surface captures a swipe.
|
|
262
|
+
const noticeResize = notices && !captureMode && new window.ResizeObserver(() => {
|
|
263
|
+
notices.classList.toggle('scrollable', notices.scrollHeight > notices.clientHeight);
|
|
264
|
+
});
|
|
265
|
+
if (noticeResize) {
|
|
266
|
+
noticeResize.observe(notices);
|
|
267
|
+
for (const child of notices.children) noticeResize.observe(child);
|
|
268
|
+
}
|
|
269
|
+
const scrollNotice = (event) => {
|
|
270
|
+
if (event.ctrlKey || event.shiftKey || !event.deltaY || notices.scrollHeight <= notices.clientHeight) return;
|
|
271
|
+
const box = notices.getBoundingClientRect();
|
|
272
|
+
const { clientX, clientY } = wheelViewportPositions.get(event) ?? event;
|
|
273
|
+
if (clientX < box.left || clientX >= box.right || clientY < box.top || clientY >= box.bottom) return;
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
event.stopPropagation();
|
|
276
|
+
const unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? notices.clientHeight : 1;
|
|
277
|
+
notices.scrollTop += event.deltaY * unit;
|
|
278
|
+
};
|
|
279
|
+
noticeViewport?.addEventListener('wheel', scrollNotice, { capture: true, passive: false });
|
|
280
|
+
|
|
281
|
+
const showPromptAlert = ({ question, waitingMs, options, since }) => {
|
|
240
282
|
const seconds = Math.round((waitingMs || 0) / 1000);
|
|
241
|
-
if (!elements.promptAlert) return;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
283
|
+
if (sessionEnded || !elements.promptAlert || !elements.promptToggle) return;
|
|
284
|
+
const samePrompt = Number.isFinite(since) ? since === promptChoice.since : promptWaiting;
|
|
285
|
+
// An identical stall frame need not change the live region or announce it again.
|
|
286
|
+
const content = JSON.stringify([seconds, question, options]);
|
|
287
|
+
if (promptWaiting && samePrompt && lastPromptContent === content) return;
|
|
288
|
+
lastPromptContent = content;
|
|
289
|
+
if (!samePrompt) {
|
|
290
|
+
promptChoice.collapsed = false;
|
|
291
|
+
}
|
|
292
|
+
promptChoice.since = since ?? null;
|
|
293
|
+
const heading = `Waiting for you: ${String(seconds)}s unanswered`;
|
|
294
|
+
elements.promptToggle.textContent = heading;
|
|
295
|
+
elements.promptToggle.hidden = false;
|
|
296
|
+
const details = document.createDocumentFragment();
|
|
297
|
+
const spokenHeading = document.createElement('span');
|
|
298
|
+
spokenHeading.className = 'prompt-announcement-heading';
|
|
299
|
+
spokenHeading.textContent = heading;
|
|
245
300
|
const question_ = document.createElement('div');
|
|
246
301
|
question_.className = 'question';
|
|
247
302
|
question_.textContent = question || '(the session is holding a prompt)';
|
|
248
|
-
|
|
303
|
+
details.append(spokenHeading, question_);
|
|
249
304
|
|
|
250
305
|
if (Array.isArray(options) && options.length > 0) {
|
|
251
306
|
const list = document.createElement('ul');
|
|
@@ -255,14 +310,10 @@ window.ShellPuppetPane = (() => {
|
|
|
255
310
|
item.textContent = option;
|
|
256
311
|
list.append(item);
|
|
257
312
|
}
|
|
258
|
-
|
|
313
|
+
details.append(list);
|
|
259
314
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
noticeKind = 'prompt';
|
|
264
|
-
elements.promptAlert.hidden = false;
|
|
265
|
-
positionNotices();
|
|
315
|
+
elements.promptAlert.replaceChildren(details);
|
|
316
|
+
renderDisclosure();
|
|
266
317
|
promptWaiting = true;
|
|
267
318
|
onAttentionChange(true);
|
|
268
319
|
refreshTitle();
|
|
@@ -270,12 +321,14 @@ window.ShellPuppetPane = (() => {
|
|
|
270
321
|
|
|
271
322
|
const clearPromptAlert = () => {
|
|
272
323
|
promptWaiting = false;
|
|
324
|
+
lastPromptContent = null;
|
|
325
|
+
promptChoice.since = null;
|
|
326
|
+
promptChoice.collapsed = false;
|
|
327
|
+
if (elements.promptToggle) elements.promptToggle.hidden = true;
|
|
273
328
|
if (providerStall) { showStallAlert(providerStall); return; }
|
|
274
329
|
if (!elements.promptAlert) return;
|
|
275
|
-
if (!elements.promptAlert.hidden) noticeHiddenAt = window.performance.now();
|
|
276
330
|
elements.promptAlert.hidden = true;
|
|
277
331
|
elements.promptAlert.textContent = '';
|
|
278
|
-
promptWaiting = false;
|
|
279
332
|
onAttentionChange(false);
|
|
280
333
|
refreshTitle();
|
|
281
334
|
};
|
|
@@ -284,12 +337,7 @@ window.ShellPuppetPane = (() => {
|
|
|
284
337
|
providerStall = stalled;
|
|
285
338
|
if (!elements.promptAlert || promptWaiting) return;
|
|
286
339
|
elements.promptAlert.textContent = `Stalled: ${stalled.reason} since ${stalled.since}. ${stalled.description}`;
|
|
287
|
-
if (elements.promptAlert.hidden || noticeKind !== 'stall') {
|
|
288
|
-
noticeNewEpisode = noticeKind !== 'stall' || noticeHiddenLong();
|
|
289
|
-
}
|
|
290
|
-
noticeKind = 'stall';
|
|
291
340
|
elements.promptAlert.hidden = false;
|
|
292
|
-
positionNotices();
|
|
293
341
|
onAttentionChange(true);
|
|
294
342
|
refreshTitle();
|
|
295
343
|
};
|
|
@@ -297,7 +345,6 @@ window.ShellPuppetPane = (() => {
|
|
|
297
345
|
const clearStallAlert = () => {
|
|
298
346
|
providerStall = null;
|
|
299
347
|
if (!promptWaiting && elements.promptAlert) {
|
|
300
|
-
if (!elements.promptAlert.hidden) noticeHiddenAt = window.performance.now();
|
|
301
348
|
elements.promptAlert.hidden = true;
|
|
302
349
|
elements.promptAlert.textContent = '';
|
|
303
350
|
}
|
|
@@ -365,6 +412,8 @@ window.ShellPuppetPane = (() => {
|
|
|
365
412
|
const screen = term.element?.querySelector('.xterm-screen');
|
|
366
413
|
if (!screen) return;
|
|
367
414
|
const rect = screen.getBoundingClientRect();
|
|
415
|
+
// The notice compares the wheel position with a viewport rectangle.
|
|
416
|
+
if (event.type === 'wheel') wheelViewportPositions.set(event, { clientX: event.clientX, clientY: event.clientY });
|
|
368
417
|
const clientX = rect.left + (event.clientX - rect.left) / fontScale;
|
|
369
418
|
const clientY = rect.top + (event.clientY - rect.top) / fontScale;
|
|
370
419
|
// Keep the original event, target and pointer id so native capture works.
|
|
@@ -486,7 +535,6 @@ window.ShellPuppetPane = (() => {
|
|
|
486
535
|
}
|
|
487
536
|
if (destroyed || !elements.copyNotice) return;
|
|
488
537
|
elements.copyNotice.hidden = false;
|
|
489
|
-
positionNotices();
|
|
490
538
|
clearTimeout(copyNoticeTimer);
|
|
491
539
|
copyNoticeTimer = setTimeout(() => { elements.copyNotice.hidden = true; }, 1500);
|
|
492
540
|
};
|
|
@@ -527,329 +575,6 @@ window.ShellPuppetPane = (() => {
|
|
|
527
575
|
return true;
|
|
528
576
|
});
|
|
529
577
|
|
|
530
|
-
let noticeBottom = null;
|
|
531
|
-
let noticeLastMove = null;
|
|
532
|
-
let noticeLastRepaint = -Infinity;
|
|
533
|
-
let noticeLegMoved = false;
|
|
534
|
-
let noticeStayPreviousRepaint;
|
|
535
|
-
let noticeStayEdge = null;
|
|
536
|
-
let noticeStaySince = null;
|
|
537
|
-
let noticeStayMoved = false;
|
|
538
|
-
let noticeAnchor = null;
|
|
539
|
-
let noticeCycle = null;
|
|
540
|
-
let noticeCycleVisits = [];
|
|
541
|
-
let noticeCycleMoves = 0;
|
|
542
|
-
const noticeVisits = [];
|
|
543
|
-
let noticeGeometry = null;
|
|
544
|
-
let noticeSeen = false;
|
|
545
|
-
let noticeNewEpisode = false;
|
|
546
|
-
let noticeHiddenAt = null;
|
|
547
|
-
// The kind of the last alert shown: a different kind is a new notice.
|
|
548
|
-
let noticeKind = null;
|
|
549
|
-
// An alert shown after the notice was hidden for the whole retained history
|
|
550
|
-
// is a new notice: none of its cadence evidence remains. A shorter gap, such
|
|
551
|
-
// as the daemon re-announcing a prompt whose choices a repaint changed,
|
|
552
|
-
// keeps the cadence.
|
|
553
|
-
const noticeHiddenLong = () => noticeHiddenAt === null ||
|
|
554
|
-
window.performance.now() - noticeHiddenAt >= NOTICE_HISTORY_MS;
|
|
555
|
-
let noticeFrame = null;
|
|
556
|
-
let noticeTimer = null;
|
|
557
|
-
let noticeEvidenceTimer = null;
|
|
558
|
-
let noticeDisposed = false;
|
|
559
|
-
|
|
560
|
-
function clearNoticeTimer() {
|
|
561
|
-
clearTimeout(noticeTimer);
|
|
562
|
-
noticeTimer = null;
|
|
563
|
-
clearTimeout(noticeEvidenceTimer);
|
|
564
|
-
noticeEvidenceTimer = null;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
function trimNoticeVisits(now) {
|
|
568
|
-
const cutoff = now - NOTICE_HISTORY_MS;
|
|
569
|
-
while (noticeVisits.length > 1 && noticeVisits[1].since <= cutoff) noticeVisits.shift();
|
|
570
|
-
if (noticeVisits.length && noticeVisits[0].since < cutoff) {
|
|
571
|
-
noticeVisits[0].since = cutoff;
|
|
572
|
-
noticeVisits[0].clipped = true;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
function noticeCoversRow(row, bottom) {
|
|
577
|
-
if (!noticeGeometry) return false;
|
|
578
|
-
const distance = bottom ? term.rows - row - 1 : row;
|
|
579
|
-
return distance * noticeGeometry.cell < noticeGeometry.height - 0.01;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
function noticeWeights(visits, now) {
|
|
583
|
-
let top = 0, bottom = 0;
|
|
584
|
-
for (let i = 0; i < visits.length; i++) {
|
|
585
|
-
const visit = visits[i];
|
|
586
|
-
const duration = Math.max(0, (visits[i + 1]?.since ?? now) - visit.since);
|
|
587
|
-
if (noticeCoversRow(visit.row, false)) top += duration;
|
|
588
|
-
if (noticeCoversRow(visit.row, true)) bottom += duration;
|
|
589
|
-
}
|
|
590
|
-
return { top, bottom };
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
function noticeClearEdge({ top, bottom }) {
|
|
594
|
-
// Cursor events are observed after this pane's listener has run. Keep
|
|
595
|
-
// a small clear lead beyond the ratio boundary for delivered evidence.
|
|
596
|
-
if (top + NOTICE_DELIVERY_GUARD_MS <= bottom * 2 / 3 &&
|
|
597
|
-
bottom - top >= NOTICE_COVER_MARGIN_MS) return false;
|
|
598
|
-
if (bottom + NOTICE_DELIVERY_GUARD_MS <= top * 2 / 3 &&
|
|
599
|
-
top - bottom >= NOTICE_COVER_MARGIN_MS) return true;
|
|
600
|
-
return null;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function finishNoticeRest() {
|
|
604
|
-
// A completed rectangle stay reclassifies an earlier move in any of
|
|
605
|
-
// its rows. Rest follows do not spend the repaint budget.
|
|
606
|
-
if (noticeStayPreviousRepaint !== undefined) {
|
|
607
|
-
noticeLastRepaint = noticeStayPreviousRepaint;
|
|
608
|
-
noticeStayPreviousRepaint = undefined;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
function rememberNoticeCycle(row, now) {
|
|
613
|
-
if (row !== noticeAnchor || !noticeGeometry) return;
|
|
614
|
-
// Keep the current anchor-return word outside the ten-second weight
|
|
615
|
-
// window. A full delivered cycle can be longer than that window.
|
|
616
|
-
let visits = noticeCycleVisits.map(visit => ({ ...visit }));
|
|
617
|
-
if (!visits.length) return;
|
|
618
|
-
const half = visits.length / 2;
|
|
619
|
-
const repeated = Number.isInteger(half) && visits.slice(0, half).every((visit, i) =>
|
|
620
|
-
visit.row === visits[i + half].row);
|
|
621
|
-
if (repeated) visits = visits.slice(half);
|
|
622
|
-
const duration = now - visits[0].since;
|
|
623
|
-
const weights = noticeWeights(visits, now);
|
|
624
|
-
let longestLeg = 0;
|
|
625
|
-
for (let i = 0; i < visits.length; i++) {
|
|
626
|
-
longestLeg = Math.max(longestLeg, (visits[i + 1]?.since ?? now) - visits[i].since);
|
|
627
|
-
}
|
|
628
|
-
noticeCycleMoves = 0;
|
|
629
|
-
if (repeated) noticeCycleVisits = noticeCycleVisits.slice(half);
|
|
630
|
-
if (weights.top <= 0 || weights.bottom <= 0) return;
|
|
631
|
-
// A repeated row word renews its evidence even when delivery makes
|
|
632
|
-
// this occurrence slightly shorter than the previous one.
|
|
633
|
-
const sameWord = noticeCycle && visits.length === noticeCycle.visits.length &&
|
|
634
|
-
visits.every((visit, i) => visit.row === noticeCycle.visits[i].row);
|
|
635
|
-
if (!noticeCycle || sameWord || now - noticeCycle.end >= noticeCycle.validFor || duration >= noticeCycle.duration) {
|
|
636
|
-
noticeCycle = { visits, end: now, duration,
|
|
637
|
-
validFor: Math.max(NOTICE_HISTORY_MS, duration + longestLeg) };
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
function placeNotices(now, immediate = false) {
|
|
642
|
-
if (!noticeGeometry || noticeGeometry.height <= 0) return;
|
|
643
|
-
const { notices, top, bottom } = noticeGeometry;
|
|
644
|
-
const row = term.buffer.active.cursorY;
|
|
645
|
-
noticeBottom ??= row < term.rows / 2;
|
|
646
|
-
trimNoticeVisits(now);
|
|
647
|
-
const quiet = noticeStayEdge !== null && now - noticeStaySince >= NOTICE_QUIET_MS;
|
|
648
|
-
if (quiet) finishNoticeRest();
|
|
649
|
-
if (!noticeLegMoved && (noticeStayEdge === null || !noticeStayMoved)) {
|
|
650
|
-
let destination = noticeBottom;
|
|
651
|
-
const initial = !noticeVisits.length || (immediate && noticeVisits.length === 1);
|
|
652
|
-
if (initial || quiet) {
|
|
653
|
-
if (noticeCoversRow(row, noticeBottom)) destination = !noticeBottom;
|
|
654
|
-
} else if (now - noticeVisits[0].since >= NOTICE_DECISION_MS &&
|
|
655
|
-
now - noticeLastRepaint >= NOTICE_HISTORY_MS && noticeCycleMoves === 0) {
|
|
656
|
-
const whole = noticeClearEdge(noticeWeights(noticeVisits, now));
|
|
657
|
-
// A short complete cycle represents a repeated cadence. Apply the
|
|
658
|
-
// absolute margin over the decision horizon, so a 24/9 ms cycle
|
|
659
|
-
// cannot veto a clear lead accumulated across many repetitions.
|
|
660
|
-
const cycle = noticeCycle && now - noticeCycle.end < noticeCycle.validFor ? (() => {
|
|
661
|
-
const weights = noticeWeights(noticeCycle.visits, noticeCycle.end);
|
|
662
|
-
const scale = Math.max(1, NOTICE_DECISION_MS / Math.max(1, noticeCycle.duration));
|
|
663
|
-
return noticeClearEdge({ top: weights.top * scale, bottom: weights.bottom * scale });
|
|
664
|
-
})() : undefined;
|
|
665
|
-
// Whole-history hysteresis and the absolute budget apply even at
|
|
666
|
-
// startup. A retained cycle can veto a move, never authorise
|
|
667
|
-
// one against the whole history.
|
|
668
|
-
if (whole !== null && (cycle === undefined || cycle === whole)) {
|
|
669
|
-
destination = whole;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
if (destination !== noticeBottom && !noticeCoversRow(row, destination)) {
|
|
673
|
-
noticeBottom = destination;
|
|
674
|
-
noticeLegMoved = true;
|
|
675
|
-
if (noticeStayEdge !== null) noticeStayMoved = true;
|
|
676
|
-
if (!initial && !quiet) {
|
|
677
|
-
if (noticeStayEdge !== null && noticeStayPreviousRepaint === undefined) {
|
|
678
|
-
noticeStayPreviousRepaint = noticeLastRepaint;
|
|
679
|
-
}
|
|
680
|
-
noticeLastRepaint = now;
|
|
681
|
-
noticeCycleMoves++;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
notices.style.top = noticeBottom ? 'auto' : `${String(top)}px`;
|
|
686
|
-
notices.style.bottom = noticeBottom ? `${String(bottom)}px` : 'auto';
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// Cursor events record occupancy without measuring the DOM. A frame
|
|
690
|
-
// coalesces placement decisions and uses the last measured geometry.
|
|
691
|
-
function sampleNoticeCursor() {
|
|
692
|
-
noticeFrame = null;
|
|
693
|
-
if (destroyed || sessionEnded) return;
|
|
694
|
-
const now = window.performance.now();
|
|
695
|
-
placeNotices(now);
|
|
696
|
-
// A frame can be delivered before an overdue timer after a long pause.
|
|
697
|
-
// Keep a callback armed while a covered stay is waiting for its deadline.
|
|
698
|
-
if (noticeStayEdge === (noticeBottom ? 'bottom' : 'top') &&
|
|
699
|
-
now - noticeStaySince < NOTICE_QUIET_MS) {
|
|
700
|
-
noticeFrame = window.requestAnimationFrame(sampleNoticeCursor);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
function settleNoticeCursor() {
|
|
705
|
-
noticeTimer = null;
|
|
706
|
-
if (destroyed || sessionEnded) return;
|
|
707
|
-
// Timer deadlines can round down relative to performance.now(). Do not
|
|
708
|
-
// consume the only quiet check a fraction before its deadline.
|
|
709
|
-
const remaining = NOTICE_QUIET_MS - (window.performance.now() - noticeStaySince);
|
|
710
|
-
if (remaining > 100) {
|
|
711
|
-
noticeTimer = setTimeout(settleNoticeCursor, remaining - 100);
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
if (noticeFrame === null) noticeFrame = window.requestAnimationFrame(sampleNoticeCursor);
|
|
715
|
-
if (remaining > 0) {
|
|
716
|
-
// The armed frame can start just before the deadline and finish just
|
|
717
|
-
// after it. Check at the deadline too, before that frame is delivered.
|
|
718
|
-
noticeTimer = setTimeout(settleNoticeCursor, remaining);
|
|
719
|
-
} else {
|
|
720
|
-
placeNotices(window.performance.now());
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
function checkNoticeEvidence() {
|
|
725
|
-
noticeEvidenceTimer = null;
|
|
726
|
-
if (destroyed || sessionEnded || (noticeStayEdge !== null &&
|
|
727
|
-
window.performance.now() - noticeStaySince >= NOTICE_QUIET_MS)) return;
|
|
728
|
-
// An active leg accumulates covered time even without cursor events.
|
|
729
|
-
// Bound decision latency without adding DOM measurements or a timer
|
|
730
|
-
// that continues after rest, disposal or the session ending.
|
|
731
|
-
if (noticeFrame === null) noticeFrame = window.requestAnimationFrame(sampleNoticeCursor);
|
|
732
|
-
noticeEvidenceTimer = setTimeout(checkNoticeEvidence, 50);
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
function scheduleNoticeCursor() {
|
|
736
|
-
if (destroyed || sessionEnded) return;
|
|
737
|
-
const row = term.buffer.active.cursorY;
|
|
738
|
-
// Horizontal typing and animation cannot distinguish a repaint from
|
|
739
|
-
// rest. Only a new row starts another leg or restarts the quiet timer.
|
|
740
|
-
const now = window.performance.now();
|
|
741
|
-
if (noticeVisits[noticeVisits.length - 1]?.row === row) return;
|
|
742
|
-
const edge = noticeCoversRow(row, false) ? 'top' : noticeCoversRow(row, true) ? 'bottom' : null;
|
|
743
|
-
if (noticeStayEdge !== null && edge !== noticeStayEdge && now - noticeStaySince >= NOTICE_QUIET_MS) {
|
|
744
|
-
// A genuine rest ends the preceding repaint. Its idle time must not
|
|
745
|
-
// outweigh the evidence delivered by the next staged redraw.
|
|
746
|
-
// Retain a zero-duration boundary so a later layout is not mistaken
|
|
747
|
-
// for the first placement of a newly shown notice.
|
|
748
|
-
noticeVisits.splice(0, noticeVisits.length - 1);
|
|
749
|
-
if (noticeVisits.length) noticeVisits[0].since = now;
|
|
750
|
-
finishNoticeRest();
|
|
751
|
-
noticeCycle = null;
|
|
752
|
-
noticeCycleVisits = [];
|
|
753
|
-
noticeCycleMoves = 0;
|
|
754
|
-
noticeAnchor = edge === null ? null : row;
|
|
755
|
-
}
|
|
756
|
-
if (edge !== noticeStayEdge) {
|
|
757
|
-
noticeStayEdge = edge;
|
|
758
|
-
noticeStaySince = edge === null ? null : now;
|
|
759
|
-
noticeStayMoved = false;
|
|
760
|
-
noticeStayPreviousRepaint = undefined;
|
|
761
|
-
}
|
|
762
|
-
trimNoticeVisits(now);
|
|
763
|
-
// An uncovered preparation row can recur within a longer repaint.
|
|
764
|
-
// Anchor a complete cycle at the first row inside either rectangle.
|
|
765
|
-
if (noticeAnchor === null && edge !== null) {
|
|
766
|
-
noticeAnchor = row;
|
|
767
|
-
noticeCycleVisits = [];
|
|
768
|
-
noticeCycleMoves = 0;
|
|
769
|
-
}
|
|
770
|
-
rememberNoticeCycle(row, now);
|
|
771
|
-
noticeLegMoved = false;
|
|
772
|
-
noticeVisits.push({ row, since: now });
|
|
773
|
-
if (noticeAnchor !== null) noticeCycleVisits.push({ row, since: now });
|
|
774
|
-
trimNoticeVisits(now);
|
|
775
|
-
noticeLastMove = now;
|
|
776
|
-
clearNoticeTimer();
|
|
777
|
-
// The final move must win even when no more cursor events arrive.
|
|
778
|
-
if (noticeStayEdge !== null) noticeTimer = setTimeout(settleNoticeCursor,
|
|
779
|
-
Math.max(0, NOTICE_QUIET_MS - (now - noticeStaySince) - 100));
|
|
780
|
-
noticeEvidenceTimer = setTimeout(checkNoticeEvidence, 50);
|
|
781
|
-
if (noticeFrame === null) noticeFrame = window.requestAnimationFrame(sampleNoticeCursor);
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
function disposeNoticeTracking() {
|
|
785
|
-
if (noticeDisposed) return;
|
|
786
|
-
noticeDisposed = true;
|
|
787
|
-
noticeCursorListener.dispose();
|
|
788
|
-
noticeResizeObserver.disconnect();
|
|
789
|
-
if (noticeFrame !== null) window.cancelAnimationFrame(noticeFrame);
|
|
790
|
-
noticeFrame = null;
|
|
791
|
-
clearNoticeTimer();
|
|
792
|
-
noticeVisits.length = 0;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
// Alerts and layout changes measure once and place from existing evidence.
|
|
796
|
-
// A held grid can be centred, so anchor to its screen, not the outer box.
|
|
797
|
-
function positionNotices(initialPlacement = false) {
|
|
798
|
-
if (destroyed) return;
|
|
799
|
-
const notices = elements.promptAlert?.parentElement || elements.banner?.parentElement;
|
|
800
|
-
const wrap = container.parentElement;
|
|
801
|
-
const screen = term.element?.querySelector('.xterm-screen');
|
|
802
|
-
if (!notices || !wrap || !screen || term.rows < 1) return;
|
|
803
|
-
const screenRect = screen.getBoundingClientRect();
|
|
804
|
-
const wrapRect = wrap.getBoundingClientRect();
|
|
805
|
-
notices.style.maxHeight = `${String(screenRect.height / 3)}px`;
|
|
806
|
-
const noticeHeight = notices.getBoundingClientRect().height;
|
|
807
|
-
const firstVisibleNotice = (!noticeSeen || noticeNewEpisode) && noticeHeight > 0;
|
|
808
|
-
if (noticeHeight > 0) { noticeSeen = true; noticeNewEpisode = false; }
|
|
809
|
-
noticeGeometry = { notices, top: screenRect.top - wrapRect.top,
|
|
810
|
-
bottom: wrapRect.bottom - screenRect.bottom, cell: screenRect.height / term.rows,
|
|
811
|
-
height: noticeHeight };
|
|
812
|
-
const now = window.performance.now();
|
|
813
|
-
const row = term.buffer.active.cursorY;
|
|
814
|
-
if (firstVisibleNotice && !sessionEnded) {
|
|
815
|
-
// Cursor time before a notice exists cannot decide its repaint edge.
|
|
816
|
-
noticeVisits.length = 0;
|
|
817
|
-
noticeVisits.push({ row, since: now });
|
|
818
|
-
noticeLastRepaint = -Infinity;
|
|
819
|
-
noticeLegMoved = false;
|
|
820
|
-
noticeStayPreviousRepaint = undefined;
|
|
821
|
-
noticeStayEdge = null;
|
|
822
|
-
noticeStaySince = null;
|
|
823
|
-
noticeStayMoved = false;
|
|
824
|
-
noticeAnchor = null;
|
|
825
|
-
noticeCycle = null;
|
|
826
|
-
noticeCycleVisits = [];
|
|
827
|
-
noticeCycleMoves = 0;
|
|
828
|
-
}
|
|
829
|
-
const edge = noticeCoversRow(row, false) ? 'top' : noticeCoversRow(row, true) ? 'bottom' : null;
|
|
830
|
-
if (edge !== noticeStayEdge) {
|
|
831
|
-
noticeStayEdge = edge;
|
|
832
|
-
noticeStaySince = edge === null ? null : now;
|
|
833
|
-
noticeStayMoved = false;
|
|
834
|
-
noticeStayPreviousRepaint = undefined;
|
|
835
|
-
clearNoticeTimer();
|
|
836
|
-
if (edge !== null && !noticeDisposed) {
|
|
837
|
-
noticeTimer = setTimeout(settleNoticeCursor, NOTICE_QUIET_MS - 100);
|
|
838
|
-
if (noticeFrame === null) noticeFrame = window.requestAnimationFrame(sampleNoticeCursor);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
// A repeated prompt control or resize must use the existing cadence.
|
|
842
|
-
// Only first visibility (including an alert after a hidden period longer
|
|
843
|
-
// than the retained history) and a completed snapshot can place immediately.
|
|
844
|
-
placeNotices(now, firstVisibleNotice || initialPlacement === true);
|
|
845
|
-
}
|
|
846
|
-
const noticeCursorListener = term.onCursorMove(scheduleNoticeCursor);
|
|
847
|
-
// Content can change height without a cursor move (including font loads).
|
|
848
|
-
const noticeResizeObserver = new window.ResizeObserver(positionNotices);
|
|
849
|
-
const noticeContainer = elements.promptAlert?.parentElement || elements.banner?.parentElement;
|
|
850
|
-
if (noticeContainer) noticeResizeObserver.observe(noticeContainer);
|
|
851
|
-
positionNotices();
|
|
852
|
-
|
|
853
578
|
if (redactedCapture) {
|
|
854
579
|
window.__shellpuppetCoverRows = (hiddenRows) => {
|
|
855
580
|
const rows = container.querySelectorAll('.xterm-rows > div');
|
|
@@ -909,7 +634,6 @@ window.ShellPuppetPane = (() => {
|
|
|
909
634
|
} else {
|
|
910
635
|
requestFit();
|
|
911
636
|
}
|
|
912
|
-
positionNotices();
|
|
913
637
|
}
|
|
914
638
|
|
|
915
639
|
function requestFit() {
|
|
@@ -1127,7 +851,6 @@ window.ShellPuppetPane = (() => {
|
|
|
1127
851
|
|
|
1128
852
|
function applyGeometry(cols, rows, max) {
|
|
1129
853
|
if (!Number.isInteger(cols) || !Number.isInteger(rows)) return;
|
|
1130
|
-
const resized = term.cols !== cols || term.rows !== rows;
|
|
1131
854
|
gridCols = cols;
|
|
1132
855
|
gridRows = rows;
|
|
1133
856
|
if (max && Number.isInteger(max.cols) && Number.isInteger(max.rows)) {
|
|
@@ -1135,12 +858,6 @@ window.ShellPuppetPane = (() => {
|
|
|
1135
858
|
}
|
|
1136
859
|
// Compare at the parser boundary: another geometry frame may be queued.
|
|
1137
860
|
resizeTerminal(cols, rows);
|
|
1138
|
-
if (resized) {
|
|
1139
|
-
// A resize during a header excursion must not discard the prompt's
|
|
1140
|
-
// occupancy. Clamp rows lost from a smaller grid; subsequent cursor
|
|
1141
|
-
// events and the quiet fallback account for the arriving snapshot.
|
|
1142
|
-
for (const visit of noticeVisits) visit.row = Math.min(visit.row, rows - 1);
|
|
1143
|
-
}
|
|
1144
861
|
if (controlMode === 'yours' && !captureMode && dashboardProof === null) {
|
|
1145
862
|
updateZoomButtons();
|
|
1146
863
|
} else {
|
|
@@ -1152,7 +869,6 @@ window.ShellPuppetPane = (() => {
|
|
|
1152
869
|
(controlMode === 'held' ? ' (fixed)' : controlMode === 'adopt' ? ' (following)' : '');
|
|
1153
870
|
elements.size.title = elements.size.textContent;
|
|
1154
871
|
}
|
|
1155
|
-
positionNotices();
|
|
1156
872
|
onGeometryChange();
|
|
1157
873
|
}
|
|
1158
874
|
|
|
@@ -1214,16 +930,13 @@ window.ShellPuppetPane = (() => {
|
|
|
1214
930
|
|
|
1215
931
|
ws.onopen = () => {
|
|
1216
932
|
if (destroyed) return;
|
|
1217
|
-
// A reconnect may have missed a clear.
|
|
1218
|
-
//
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
firstFrameSeen = false;
|
|
1224
|
-
}
|
|
933
|
+
// A reconnect may have missed a clear. Only the daemon's replay can
|
|
934
|
+
// show the prompt again and identify it as the one the person folded.
|
|
935
|
+
firstFrameSeen = false;
|
|
936
|
+
promptWaiting = false;
|
|
937
|
+
lastPromptContent = null;
|
|
938
|
+
if (elements.promptToggle) elements.promptToggle.hidden = true;
|
|
1225
939
|
clearStallAlert();
|
|
1226
|
-
if (reconnected) noticeHiddenAt = null;
|
|
1227
940
|
everConnected = true;
|
|
1228
941
|
if (elements.dot) elements.dot.classList.remove('off');
|
|
1229
942
|
if (elements.banner) elements.banner.hidden = true;
|
|
@@ -1242,31 +955,10 @@ window.ShellPuppetPane = (() => {
|
|
|
1242
955
|
if (destroyed) return;
|
|
1243
956
|
if (event.data instanceof ArrayBuffer) {
|
|
1244
957
|
if (redactedCapture && window.__shellpuppetPainted === true) return;
|
|
1245
|
-
if (!firstFrameSeen) {
|
|
958
|
+
if (captureMode && !firstFrameSeen) {
|
|
1246
959
|
firstFrameSeen = true;
|
|
1247
960
|
writeTerminal(new Uint8Array(event.data), () => {
|
|
1248
961
|
if (destroyed) return;
|
|
1249
|
-
// Snapshot parsing is asynchronous and may follow an ended
|
|
1250
|
-
// identity or an alert. Its intermediate rows are not repaint
|
|
1251
|
-
// history. Place once at its final cursor, even after tracking
|
|
1252
|
-
// has been disposed; ordinary stream chunks need no layout.
|
|
1253
|
-
noticeVisits.length = 0;
|
|
1254
|
-
noticeLegMoved = false;
|
|
1255
|
-
noticeStayPreviousRepaint = undefined;
|
|
1256
|
-
noticeLastRepaint = -Infinity;
|
|
1257
|
-
noticeCycle = null;
|
|
1258
|
-
noticeAnchor = null;
|
|
1259
|
-
noticeCycleVisits = [];
|
|
1260
|
-
noticeCycleMoves = 0;
|
|
1261
|
-
noticeStayEdge = null;
|
|
1262
|
-
noticeStaySince = null;
|
|
1263
|
-
noticeStayMoved = false;
|
|
1264
|
-
if (!noticeDisposed) {
|
|
1265
|
-
noticeLastMove = window.performance.now();
|
|
1266
|
-
noticeVisits.push({ row: term.buffer.active.cursorY, since: noticeLastMove });
|
|
1267
|
-
}
|
|
1268
|
-
positionNotices(true);
|
|
1269
|
-
if (!captureMode) return;
|
|
1270
962
|
window.requestAnimationFrame(() => {
|
|
1271
963
|
if (destroyed) return;
|
|
1272
964
|
window.requestAnimationFrame(() => {
|
|
@@ -1392,7 +1084,7 @@ window.ShellPuppetPane = (() => {
|
|
|
1392
1084
|
if (control.reason === 'exited') showEnded(control.exitCode);
|
|
1393
1085
|
else if (control.reason === 'input-failed') showInputFailed();
|
|
1394
1086
|
} else if (control && control.type === 'prompt-stall') {
|
|
1395
|
-
showPromptAlert(control
|
|
1087
|
+
showPromptAlert(control);
|
|
1396
1088
|
} else if (control && control.type === 'prompt-clear') {
|
|
1397
1089
|
clearPromptAlert();
|
|
1398
1090
|
} else if (control && control.type === 'session-stalled') {
|
|
@@ -1443,12 +1135,17 @@ window.ShellPuppetPane = (() => {
|
|
|
1443
1135
|
term.textarea.removeEventListener('blur', forgetGesture);
|
|
1444
1136
|
window.removeEventListener('blur', forgetGesture);
|
|
1445
1137
|
}
|
|
1138
|
+
noticeViewport?.removeEventListener('wheel', scrollNotice, true);
|
|
1139
|
+
if (noticeResize) noticeResize.disconnect();
|
|
1140
|
+
elements.promptToggle?.removeEventListener('click', togglePrompt);
|
|
1141
|
+
elements.promptToggle?.removeEventListener('keydown', onPromptKeyDown);
|
|
1142
|
+
if (elements.promptToggle) elements.promptToggle.hidden = true;
|
|
1143
|
+
if (elements.promptAlert) elements.promptAlert.hidden = true;
|
|
1446
1144
|
clearTimeout(copyNoticeTimer);
|
|
1447
1145
|
if (elements.copyNotice) elements.copyNotice.hidden = true;
|
|
1448
1146
|
fontListeners.delete(refreshFontMetrics);
|
|
1449
1147
|
resolutionListener.dispose();
|
|
1450
1148
|
if (metricsFrame !== null) window.cancelAnimationFrame(metricsFrame);
|
|
1451
|
-
disposeNoticeTracking();
|
|
1452
1149
|
if (scaledSelection === container) scaledSelection = null;
|
|
1453
1150
|
for (const type of scaledMouseEvents) document.removeEventListener(type, scaleMouseEvent, true);
|
|
1454
1151
|
outerScroll?.removeEventListener('wheel', scrollOversizedPane, true);
|
|
@@ -1503,7 +1200,6 @@ window.ShellPuppetPane = (() => {
|
|
|
1503
1200
|
if (destroyed) return;
|
|
1504
1201
|
dashboardFontLimit = font;
|
|
1505
1202
|
if (geometryDecided) applyFontPreference(gridCols, gridRows);
|
|
1506
|
-
positionNotices();
|
|
1507
1203
|
},
|
|
1508
1204
|
registerLayout(eligible, real = true) {
|
|
1509
1205
|
if (real && (!ws || ws.readyState !== 1 || !geometryDecided)) pendingRealLayout = true;
|