synabun 2.4.2 → 2.4.4
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/CHANGELOG.md +39 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +83 -34
- package/lib/release-npm-ci.mjs +23 -1
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +8 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +2 -0
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +4 -0
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/memory-client.d.ts +5 -0
- package/mcp-server/dist/services/memory-client.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-client.js +21 -2
- package/mcp-server/dist/services/memory-client.js.map +1 -1
- package/mcp-server/dist/services/memory-writer.d.ts +3 -0
- package/mcp-server/dist/services/memory-writer.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-writer.js +7 -1
- package/mcp-server/dist/services/memory-writer.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +11 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +68 -18
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +38 -2
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +260 -8
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +3 -1
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +11 -6
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.js +8 -2
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +11 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +113 -27
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/browser-readers.d.ts +6 -0
- package/mcp-server/dist/tools/browser-readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-readers.js +17 -0
- package/mcp-server/dist/tools/browser-readers.js.map +1 -0
- package/mcp-server/dist/tools/remember.d.ts.map +1 -1
- package/mcp-server/dist/tools/remember.js +6 -2
- package/mcp-server/dist/tools/remember.js.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/analytics.js +25 -20
- package/mcp-server/dist/tools/youtube/analytics.js.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts +5 -1
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +7 -3
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.d.ts +2 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/navigate.js +5 -3
- package/mcp-server/dist/tools/youtube/navigate.js.map +1 -1
- package/mcp-server/dist/tools/youtube/playlist.js +2 -2
- package/mcp-server/dist/tools/youtube/playlist.js.map +1 -1
- package/mcp-server/dist/tools/youtube/readers.d.ts +4 -0
- package/mcp-server/dist/tools/youtube/readers.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/readers.js +15 -0
- package/mcp-server/dist/tools/youtube/readers.js.map +1 -0
- package/mcp-server/package-lock.json +5 -5
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +8 -1
- package/mcp-server/src/services/identity.ts +5 -0
- package/mcp-server/src/services/memory-client.ts +32 -12
- package/mcp-server/src/services/memory-writer.ts +5 -2
- package/mcp-server/src/services/neural-interface.ts +66 -19
- package/mcp-server/src/services/typesafe-config.ts +268 -7
- package/mcp-server/src/tools/agents.ts +12 -6
- package/mcp-server/src/tools/browser-extension-setup.ts +8 -2
- package/mcp-server/src/tools/browser-observe.ts +117 -28
- package/mcp-server/src/tools/browser-readers.ts +19 -0
- package/mcp-server/src/tools/remember.ts +6 -1
- package/mcp-server/src/tools/youtube/analytics.ts +26 -28
- package/mcp-server/src/tools/youtube/helpers.ts +8 -2
- package/mcp-server/src/tools/youtube/navigate.ts +6 -7
- package/mcp-server/src/tools/youtube/playlist.ts +2 -2
- package/mcp-server/src/tools/youtube/readers.ts +15 -0
- package/neural-interface/i18n/en.json +189 -1
- package/neural-interface/i18n/pt-BR.json +196 -8
- package/neural-interface/lib/assistant-api.js +123 -0
- package/neural-interface/lib/assistant-brains/claude.js +10 -0
- package/neural-interface/lib/assistant-brains/opencode.js +121 -7
- package/neural-interface/lib/assistant-dispatch.js +302 -44
- package/neural-interface/lib/assistant-envelope.js +40 -0
- package/neural-interface/lib/assistant-memory.js +3 -1
- package/neural-interface/lib/assistant-persona.js +6 -0
- package/neural-interface/lib/assistant-router.js +18 -8
- package/neural-interface/lib/assistant-runtime.js +182 -11
- package/neural-interface/lib/assistant-task-prompt.js +15 -2
- package/neural-interface/lib/browser-connection-state.js +20 -0
- package/neural-interface/lib/browser-extension-adapter.js +221 -17
- package/neural-interface/lib/browser-extension-archive.js +149 -0
- package/neural-interface/lib/browser-extension-bridge.js +46 -10
- package/neural-interface/lib/browser-extension-folder.js +635 -76
- package/neural-interface/lib/browser-extension-package.js +201 -0
- package/neural-interface/lib/browser-extension-pin.js +84 -0
- package/neural-interface/lib/browser-extension-pin.json +35 -0
- package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +111 -13
- package/neural-interface/lib/browser-extension-setup.js +108 -19
- package/neural-interface/lib/browser-extension-update.js +104 -0
- package/neural-interface/lib/browser-extraction.js +38 -14
- package/neural-interface/lib/claude-bg-tasks.js +183 -0
- package/neural-interface/lib/claude-history.js +12 -1
- package/neural-interface/lib/cli-install.js +23 -3
- package/neural-interface/lib/cli-update-planner.js +67 -4
- package/neural-interface/lib/confined-fs.js +25 -0
- package/neural-interface/lib/coordination/operations.js +2 -0
- package/neural-interface/lib/db.js +39 -16
- package/neural-interface/lib/editor-completion-opencode.js +2 -2
- package/neural-interface/lib/git-bash/manager.js +28 -3
- package/neural-interface/lib/git-status-runner.js +31 -3
- package/neural-interface/lib/loop-inventory.js +162 -0
- package/neural-interface/lib/loop-stall.js +74 -4
- package/neural-interface/lib/memory-session-capture.js +157 -66
- package/neural-interface/lib/native-loop-providers.js +82 -13
- package/neural-interface/lib/native-loop-runtime.js +23 -2
- package/neural-interface/lib/opencode-protocol.js +4 -2
- package/neural-interface/lib/opencode-shell-read.js +107 -0
- package/neural-interface/lib/opencode-stop-failures.js +40 -0
- package/neural-interface/lib/opencode-turn-release.js +173 -0
- package/neural-interface/lib/opencode-v2-client.js +4 -1
- package/neural-interface/lib/opencode-v2-ws-requests.js +34 -0
- package/neural-interface/lib/opencode2-client.js +341 -6
- package/neural-interface/lib/opencode2-translate.js +161 -4
- package/neural-interface/lib/peer-identity.js +62 -16
- package/neural-interface/lib/session-cache-builder.js +66 -18
- package/neural-interface/lib/session-capture-gate.js +42 -0
- package/neural-interface/lib/session-indexer.js +28 -20
- package/neural-interface/lib/teams/scheduler.js +3 -2
- package/neural-interface/lib/terminal-token-redaction.js +83 -0
- package/neural-interface/lib/ui-blob-api.js +14 -5
- package/neural-interface/lib/ui-blob-store.js +302 -39
- package/neural-interface/lib/whatsapp/bridge.js +52 -6
- package/neural-interface/package-lock.json +5 -5
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +6 -2
- package/neural-interface/public/shared/agy/agy-panel.js +38 -10
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +4 -0
- package/neural-interface/public/shared/assistant/asst-api.js +67 -0
- package/neural-interface/public/shared/assistant/asst-composer.js +85 -12
- package/neural-interface/public/shared/assistant/asst-panel.js +354 -11
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +23 -0
- package/neural-interface/public/shared/assistant/asst-render.js +343 -10
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -0
- package/neural-interface/public/shared/assistant/asst-shell-logic.js +200 -0
- package/neural-interface/public/shared/assistant/asst-shell.js +111 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +18 -1
- package/neural-interface/public/shared/assistant/asst-state.js +241 -2
- package/neural-interface/public/shared/assistant/asst-steer.js +294 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +21 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-claude.js +147 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-model.js +527 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-panel.js +161 -0
- package/neural-interface/public/shared/bg-tasks/bg-tasks-view.js +508 -0
- package/neural-interface/public/shared/browser-extension-updates.js +88 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +25 -0
- package/neural-interface/public/shared/cp/cp-bg-tasks.js +130 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +25 -12
- package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
- package/neural-interface/public/shared/extension-update-view.js +34 -0
- package/neural-interface/public/shared/mtc/mtc-panel.js +17 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +5 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +34 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +26 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +39 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +20 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-block.js +165 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +350 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell.js +108 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +49 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +40 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +20 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +7 -2
- package/neural-interface/public/shared/settings/settings-browser-extension.js +61 -13
- package/neural-interface/public/shared/settings/settings-extension-update.js +114 -0
- package/neural-interface/public/shared/shell-stop-view.js +83 -0
- package/neural-interface/public/shared/styles.css +4 -0
- package/neural-interface/public/shared/tour/tour-actor.js +14 -3
- package/neural-interface/public/shared/tray-auto-close.js +36 -6
- package/neural-interface/public/shared/ui-claude-panel.js +130 -1
- package/neural-interface/public/shared/ui-native-loop-router.js +45 -3
- package/neural-interface/public/shared/ui-notifications.js +23 -4
- package/neural-interface/public/shared/ui-scroll-follow.js +4 -0
- package/neural-interface/public/shared/ui-settings-entry.js +6 -0
- package/neural-interface/public/shared/ui-tray-columns.js +9 -2
- package/neural-interface/public/shared/worker-end.js +18 -0
- package/neural-interface/scripts/patch-node-pty.mjs +151 -0
- package/neural-interface/scripts/rebuild-pty.js +10 -0
- package/neural-interface/server.js +725 -308
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -2
- package/browser-extension/content.js +0 -231
- package/browser-extension/engine.js +0 -658
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +0 -58
- package/browser-extension/popup-strings.js +0 -250
- package/browser-extension/popup-view.js +0 -151
- package/browser-extension/popup.css +0 -166
- package/browser-extension/popup.html +0 -108
- package/browser-extension/popup.js +0 -359
- package/browser-extension/service-worker.js +0 -283
- package/browser-extension/setup-content.js +0 -36
- package/browser-extension/tokens.css +0 -326
|
@@ -45,6 +45,8 @@ import { normalizeSession, changedStartSettings, sessionFlags, sessionRows, fast
|
|
|
45
45
|
import { renderSessionSettingsCard } from './cp/cp-session-settings.js';
|
|
46
46
|
import { describeOrigin, reconcileTasks, adoptLiveTasks, describeHistorySystemRow, workEndedByRestart, isTaskRunning, endRunningTasks, backgroundWaitLine } from './cp/cp-tasks-model.js';
|
|
47
47
|
import { renderTasksCard } from './cp/cp-tasks.js';
|
|
48
|
+
import { attachClaudeBgTasks, settleClaudeBgStop, historyNoticeCards, markClaudeStaleCards, wireNoticeCardClicks } from './cp/cp-bg-tasks.js';
|
|
49
|
+
import { paintBgBadge } from './bg-tasks/bg-tasks-view.js';
|
|
48
50
|
import { sessionListLabel, collectTags, tagSession as tagClaudeSession, sessionActionsAvailable, sessionOpsSupported, labelledSessionIds, mergeSessionSearch, writeSessionTitle, forkSession as forkClaudeSession, deleteSession as deleteClaudeSession, fetchSubagentMessages, forkTitle, entryBefore, promptText, removeFrom, sessionRowParts, fillSelectOptions } from './cp/cp-sessions.js';
|
|
49
51
|
import { contextCard, usageCard, mcpRows, rewindPreviewText, rewindResultText } from './cp/cp-usage-model.js';
|
|
50
52
|
import { permissionModesFor, isDefaultableMode, autoModeSupported, grantedRuleLine, permissionRuleSections, hasSessionRules, MODE_HINTS, TOOL_POLICIES, toolPolicyId, bypassOffer, modeControl, BYPASS_MODE, pickMode, leavePlanMode, statedMode, modeStatement, planExitTarget, sessionReport, sessionEnteredPlan, statementSent, statementDropped, connectionOpened, sessionForgotten, controlFacts, savedMode, restoredMode, runEvent, isPermissionsCommand, reportReceived, modeTooltip, settingsDefaultMode, settingsModeNote } from './cp/cp-permission-model.js';
|
|
@@ -56,6 +58,7 @@ import { historyHasResultSupport, historyResultsNotice, snapshotWantsResults, fu
|
|
|
56
58
|
import { CP_STYLES } from './cp/cp-styles.js';
|
|
57
59
|
import { TEMPORARY_CAPABILITY, keepsNothing, chooseTemporary, applyTemporary, temporaryRefusal, endTemporary, leaveTemporary, tabAfterTemporary, persistableTabs, temporaryBlocks, reattaches } from './cp/cp-temporary.js';
|
|
58
60
|
import { paintTemporary } from './cp/cp-temporary-view.js';
|
|
61
|
+
import { composerHoldsDraft, markAutoCloseKeep } from './tray-auto-close.js';
|
|
59
62
|
import { renderMarkdown } from './cp/cp-markdown.js';
|
|
60
63
|
import { synabunToolKey, synabunToolLabel, synabunToolSummary, synabunToolGroup } from './synabun-tools.js';
|
|
61
64
|
import { normalizeToolHeartbeat } from './tool-heartbeat.js';
|
|
@@ -361,6 +364,9 @@ function buildPanel() {
|
|
|
361
364
|
<button class="cp-header-btn cp-new-btn" data-tooltip="New session">
|
|
362
365
|
<svg viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
|
363
366
|
</button>
|
|
367
|
+
<button class="cp-header-btn cp-bg-btn" id="cp-bg-btn" type="button" data-tooltip="Background tasks" aria-label="Background tasks" aria-pressed="false" hidden>
|
|
368
|
+
<svg viewBox="0 0 24 24"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
|
|
369
|
+
</button>
|
|
364
370
|
<button class="cp-header-btn cp-cog-btn" id="cp-cog-btn" type="button" data-tooltip="Context settings" aria-label="Context settings" aria-haspopup="dialog" aria-expanded="false" aria-controls="cp-context-popover">
|
|
365
371
|
<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>
|
|
366
372
|
<span class="cp-cog-dot" hidden></span>
|
|
@@ -1914,6 +1920,11 @@ function injectStyles() {
|
|
|
1914
1920
|
.cp-header-btn:active { transform: scale(0.92); transition-duration: 0.06s; }
|
|
1915
1921
|
.cp-header-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
1916
1922
|
.cp-header-btn.cp-new-btn:hover { color: rgba(110,181,255,0.95); background: rgba(110,181,255,0.14); }
|
|
1923
|
+
/* Background tasks toggle: a square like its neighbours; the view's count sits on its corner while tasks run
|
|
1924
|
+
(bg-tasks-view.js, corner form), ringed in the header's background. */
|
|
1925
|
+
.cp-header-btn.cp-bg-btn[hidden] { display: none; }
|
|
1926
|
+
.cp-header-btn.cp-bg-btn { --sbt-badge-ring: rgb(22, 22, 26); }
|
|
1927
|
+
.cp-header-btn.cp-bg-btn.active { color: var(--accent-gold); background: var(--accent-gold-bg); }
|
|
1917
1928
|
.cp-header-btn.cp-minimize-btn:hover { color: rgba(255,200,50,0.95); background: rgba(255,200,50,0.14); }
|
|
1918
1929
|
.cp-header-btn.cp-close-btn:hover { color: rgba(255,82,82,0.95); background: rgba(255,82,82,0.14); }
|
|
1919
1930
|
.cp-header-btn.cp-close-btn svg { stroke-width: 2.5; }
|
|
@@ -2983,6 +2994,7 @@ function createTab(sessionId = null, label = 'New chat', { autoSwitch = true, id
|
|
|
2983
2994
|
// shells and wakeups its session kept on the server).
|
|
2984
2995
|
connectTab(tab);
|
|
2985
2996
|
// Create pill (rendered in shared tray, not inside panel)
|
|
2997
|
+
_attachBg(tab);
|
|
2986
2998
|
tab.pillEl = _createTrayPill(tab);
|
|
2987
2999
|
_paintTemporary(tab);
|
|
2988
3000
|
_tabs.push(tab);
|
|
@@ -3077,6 +3089,7 @@ function switchTab(idx) {
|
|
|
3077
3089
|
}
|
|
3078
3090
|
_activeTabIdx = idx;
|
|
3079
3091
|
const tab = activeTab();
|
|
3092
|
+
_syncBgView(tab);
|
|
3080
3093
|
tab.messagesEl._exitToken = (tab.messagesEl._exitToken || 0) + 1; // cancel pending exits
|
|
3081
3094
|
_attachMessagesEl(tab);
|
|
3082
3095
|
tab.messagesEl.style.display = '';
|
|
@@ -3219,6 +3232,7 @@ function closeTab(idx, { detachAutomation = false } = {}) {
|
|
|
3219
3232
|
tab.rowWatcher?.disconnect();
|
|
3220
3233
|
tab.rowWatcher = null;
|
|
3221
3234
|
tab.messagesEl.remove();
|
|
3235
|
+
try { tab.bg?.dispose({ forget: true }); } catch {}
|
|
3222
3236
|
if (tab.pillEl) tab.pillEl.remove();
|
|
3223
3237
|
_tabs.splice(idx, 1);
|
|
3224
3238
|
if (_tabs.length === 0) {
|
|
@@ -3250,6 +3264,7 @@ function _createTrayPill(tab) {
|
|
|
3250
3264
|
pill.className = 'term-minimized-pill cp-session-pill';
|
|
3251
3265
|
pill.dataset.tabId = tab.id;
|
|
3252
3266
|
pill.getAutomationRunId = () => tab.automationRunId;
|
|
3267
|
+
pill.keepFromAutoClose = () => _autoCloseKeep(tab);
|
|
3253
3268
|
pill.innerHTML = `
|
|
3254
3269
|
<span class="cp-pill-ring" aria-hidden="true"><i></i></span>
|
|
3255
3270
|
<span class="term-minimized-pill-icon">${_CP_ICON_SVG}</span>
|
|
@@ -3344,6 +3359,25 @@ function paintPillState(pill, tab) {
|
|
|
3344
3359
|
const needsYou = tabNeedsYou(tab);
|
|
3345
3360
|
pill.classList.toggle('cp-pill-attention', needsYou);
|
|
3346
3361
|
pill.classList.toggle('cp-pill-running', !needsYou && tabWorking(tab));
|
|
3362
|
+
markAutoCloseKeep(pill, _autoCloseKeep(tab));
|
|
3363
|
+
// "⟳ N" while background tasks run: a click opens the tab on its Background tasks view.
|
|
3364
|
+
paintBgBadge(pill, tab.bg?.counts().running || 0, { t, onClick: () => _openBgFromPill(tab) });
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
/**
|
|
3368
|
+
* What the tray's auto-close must leave open (tray-auto-close.js), or '': a temporary chat,
|
|
3369
|
+
* whose close ends it for good (it keeps no transcript), and a tab holding an unsent draft (its text, in the
|
|
3370
|
+
* composer while the tab is the one on screen, and its attached images and files). The user's X closes both.
|
|
3371
|
+
* Also a tab with prompts in its queue that were never sent: a paused queue, one stranded behind another
|
|
3372
|
+
* conversation, or the one being taken off it (`_queueSending`). renderQueue repaints the mark at every change.
|
|
3373
|
+
*/
|
|
3374
|
+
function _autoCloseKeep(tab) {
|
|
3375
|
+
if (!tab) return '';
|
|
3376
|
+
if (keepsNothing(tab)) return 'temporary';
|
|
3377
|
+
if (tab.queue?.length || tab._queueSending) return 'queue';
|
|
3378
|
+
if (tab.bg?.counts().running) return 'background';
|
|
3379
|
+
const $input = tab === activeTab() ? _panel?.querySelector('#cp-input') : null;
|
|
3380
|
+
return composerHoldsDraft($input ? $input.value : tab.draft, tab.attachedImages, tab.attachedFiles) ? 'draft' : '';
|
|
3347
3381
|
}
|
|
3348
3382
|
|
|
3349
3383
|
// Whether each tab was saved needing you: a change is written at once, for the placeholder a reload
|
|
@@ -4910,6 +4944,11 @@ function _renderHistoryRow(tab, $msgs, m) {
|
|
|
4910
4944
|
renderCompactBoundary({ messagesEl: $msgs }, m);
|
|
4911
4945
|
return;
|
|
4912
4946
|
}
|
|
4947
|
+
// A background task's report, as the server read it: a card linked to its task.
|
|
4948
|
+
if (m.role === 'system' && m.subtype === 'origin' && Array.isArray(m.notifications) && m.notifications.length) {
|
|
4949
|
+
for (const card of historyNoticeCards(tab, m, t)) $msgs.appendChild(card);
|
|
4950
|
+
return;
|
|
4951
|
+
}
|
|
4913
4952
|
// What started a turn nobody typed, a warning the CLI wrote, a command's output.
|
|
4914
4953
|
const view = describeHistorySystemRow(m);
|
|
4915
4954
|
if (!view) return;
|
|
@@ -5589,10 +5628,83 @@ function _onSessionState(tab, state) {
|
|
|
5589
5628
|
}, IDLE_STATE_GRACE_MS);
|
|
5590
5629
|
}
|
|
5591
5630
|
|
|
5631
|
+
// ── Background tasks view (public/shared/bg-tasks/, cp/cp-bg-tasks.js) ──
|
|
5632
|
+
// Per tab: a registry built from the session's own stream and rebuilt from its transcript, the view that takes
|
|
5633
|
+
// the transcript's place, the header toggle and the pill's "⟳ N".
|
|
5634
|
+
function _attachBg(tab) {
|
|
5635
|
+
attachClaudeBgTasks(tab, {
|
|
5636
|
+
storage, t,
|
|
5637
|
+
project: () => _historyProject(tab),
|
|
5638
|
+
onChange: () => {
|
|
5639
|
+
if (tab.pillEl) paintPillState(tab.pillEl, tab);
|
|
5640
|
+
if (tab === activeTab()) _paintBgButton(tab);
|
|
5641
|
+
markClaudeStaleCards(tab);
|
|
5642
|
+
},
|
|
5643
|
+
// The view's own Back: the tab shows its conversation again.
|
|
5644
|
+
onShownChange: (shown) => { if (!shown && tab === activeTab()) { tab._bgOpen = false; _paintBgButton(tab); } },
|
|
5645
|
+
});
|
|
5646
|
+
wireNoticeCardClicks(tab.messagesEl, (taskId) => _openBgView(tab, taskId));
|
|
5647
|
+
}
|
|
5648
|
+
function _bgHost() { return _panel?.querySelector('#cp-messages-container') || null; }
|
|
5649
|
+
function _openBgView(tab, taskId = null) {
|
|
5650
|
+
if (!tab?.bg) return;
|
|
5651
|
+
tab._bgOpen = true;
|
|
5652
|
+
if (tab === activeTab()) tab.bg.show(_bgHost(), taskId);
|
|
5653
|
+
_paintBgButton(tab);
|
|
5654
|
+
}
|
|
5655
|
+
function _toggleBgView(tab) {
|
|
5656
|
+
if (!tab?.bg) return;
|
|
5657
|
+
if (tab._bgOpen && tab.bg.isShown()) { tab._bgOpen = false; tab.bg.hide(); _paintBgButton(tab); return; }
|
|
5658
|
+
_openBgView(tab);
|
|
5659
|
+
}
|
|
5660
|
+
// From a pill: the panel and the tab first, then the view.
|
|
5661
|
+
function _openBgFromPill(tab) {
|
|
5662
|
+
const idx = _tabs.indexOf(tab);
|
|
5663
|
+
if (idx < 0) return;
|
|
5664
|
+
if (!_visible) toggleClaudePanel();
|
|
5665
|
+
switchTab(idx);
|
|
5666
|
+
focusSidepanel(PANEL_OWNER);
|
|
5667
|
+
_openBgView(tab);
|
|
5668
|
+
}
|
|
5669
|
+
function _syncBgView(active) {
|
|
5670
|
+
for (const t2 of _tabs) {
|
|
5671
|
+
if (!t2.bg) continue;
|
|
5672
|
+
if (t2 === active && t2._bgOpen) t2.bg.show(_bgHost());
|
|
5673
|
+
else if (t2.bg.isShown()) { const keep = t2._bgOpen; t2.bg.hide(); t2._bgOpen = keep; }
|
|
5674
|
+
}
|
|
5675
|
+
_paintBgButton(active);
|
|
5676
|
+
}
|
|
5677
|
+
function _paintBgButton(tab) {
|
|
5678
|
+
const btn = _panel?.querySelector('#cp-bg-btn');
|
|
5679
|
+
if (!btn) return;
|
|
5680
|
+
const counts = tab?.bg?.counts() || { running: 0, total: 0 };
|
|
5681
|
+
const open = !!(tab?._bgOpen && tab.bg?.isShown());
|
|
5682
|
+
btn.hidden = !counts.total && !open;
|
|
5683
|
+
btn.classList.toggle('active', open);
|
|
5684
|
+
btn.setAttribute('aria-pressed', String(open));
|
|
5685
|
+
const label = t('bgTasks.toggle') !== 'bgTasks.toggle' ? t('bgTasks.toggle') : 'Background tasks';
|
|
5686
|
+
btn.setAttribute('aria-label', label);
|
|
5687
|
+
btn.dataset.tooltip = label;
|
|
5688
|
+
paintBgBadge(btn, counts.running, { t, corner: true, onClick: () => _toggleBgView(tab) });
|
|
5689
|
+
}
|
|
5690
|
+
// The tab's session is known (a new one, a reattach): the list is that session's, rebuilt from its transcript.
|
|
5691
|
+
// Once per session from an init (every turn sends one), and again at every reattach (`force`: a reload, a restart).
|
|
5692
|
+
function _bgSessionSeen(tab, { force = false } = {}) {
|
|
5693
|
+
if (!tab?.bg || !tab.sessionId || keepsNothing(tab)) return;
|
|
5694
|
+
const same = tab._bgSession === tab.sessionId;
|
|
5695
|
+
if (tab._bgSession && !same) tab.bg.reset(`claude:${tab.sessionId}`);
|
|
5696
|
+
else tab.bg.setKey(`claude:${tab.sessionId}`);
|
|
5697
|
+
tab._bgSession = tab.sessionId;
|
|
5698
|
+
if (same && !force) return;
|
|
5699
|
+
tab.bg.rebuild().then(() => markClaudeStaleCards(tab)).catch(() => {});
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5592
5702
|
// Background tasks the CLI is running for this tab after their turn ended
|
|
5593
5703
|
// (background_tasks_changed / reattach_result). Ambient ones — housekeeping,
|
|
5594
5704
|
// watchers — keep the session alive but stay out of the indicator.
|
|
5595
5705
|
function _setBackgroundWork(tab, tasks) {
|
|
5706
|
+
// The Background tasks view: the live set says what still runs.
|
|
5707
|
+
try { tab.bg?.onLive(tasks); } catch {}
|
|
5596
5708
|
// A background command whose task id left the live list has ended.
|
|
5597
5709
|
try { reconcileBgTasks(tab, tasks); } catch {}
|
|
5598
5710
|
// The list is the authority: a task this tab has no entry for (the page was
|
|
@@ -5695,6 +5807,7 @@ function _processTabMsg(tab, msg) {
|
|
|
5695
5807
|
// Prompts queued behind a Compact when the socket closed: the session is there.
|
|
5696
5808
|
if (tab._queueWaits === 'session') _compactQueue.after(tab, 'reattached');
|
|
5697
5809
|
_setBackgroundWork(tab, msg.backgroundTasks);
|
|
5810
|
+
_bgSessionSeen(tab, { force: true });
|
|
5698
5811
|
// The wakeups scheduled for the session, with their schedule and prompt.
|
|
5699
5812
|
if (Array.isArray(msg.sessionCronList)) tab.sessionCrons = msg.sessionCronList;
|
|
5700
5813
|
// What "Always" granted in this session (the bridge's record).
|
|
@@ -5706,6 +5819,7 @@ function _processTabMsg(tab, msg) {
|
|
|
5706
5819
|
// has anything to finish — and not if a new turn already started on the
|
|
5707
5820
|
// fresh socket. Idle tabs are left alone.
|
|
5708
5821
|
_setBackgroundWork(tab, []);
|
|
5822
|
+
_bgSessionSeen(tab, { force: true });
|
|
5709
5823
|
// The session is gone and so is what was known of its mode. A pick made
|
|
5710
5824
|
// while the socket was down is said to the new one first.
|
|
5711
5825
|
sessionForgotten(tab);
|
|
@@ -5744,6 +5858,8 @@ function _processTabMsg(tab, msg) {
|
|
|
5744
5858
|
break;
|
|
5745
5859
|
}
|
|
5746
5860
|
case 'task_control_result':
|
|
5861
|
+
// A Stop from the Background tasks view hears its answer there (and says it there).
|
|
5862
|
+
if (settleClaudeBgStop(tab, msg)) break;
|
|
5747
5863
|
if (!msg.ok) appendStatus(tab, `${msg.action === 'stop_task' ? 'Could not stop the task' : 'Could not send it to the background'}: ${msg.error || 'unknown error'}`);
|
|
5748
5864
|
else if (msg.action === 'background_tasks') appendStatus(tab, 'Sent to the background: it keeps running and reports back when done.');
|
|
5749
5865
|
break;
|
|
@@ -5884,6 +6000,9 @@ function handleTabEvent(tab, ev) {
|
|
|
5884
6000
|
// renderers below work unchanged.
|
|
5885
6001
|
const _parentId = ev.parent_tool_use_id || ev.message?.parent_tool_use_id || null;
|
|
5886
6002
|
const scope = _parentId ? ensureAgentScope(tab, _parentId) : tab;
|
|
6003
|
+
// The Background tasks registry (public/shared/bg-tasks/): calls, results, notices, the live set.
|
|
6004
|
+
let _bgCards = [];
|
|
6005
|
+
try { _bgCards = tab.bg ? tab.bg.onEvent(ev) : []; } catch { _bgCards = []; }
|
|
5887
6006
|
|
|
5888
6007
|
// ── New SDK-engine event types ──
|
|
5889
6008
|
if (ev.type === 'mode_behind') {
|
|
@@ -5945,7 +6064,11 @@ function handleTabEvent(tab, ev) {
|
|
|
5945
6064
|
}
|
|
5946
6065
|
// A turn nobody typed: say what started it (a background task reporting
|
|
5947
6066
|
// back, a scheduled wakeup, another session).
|
|
5948
|
-
if (!_parentId &&
|
|
6067
|
+
if (!_parentId && _bgCards.length) {
|
|
6068
|
+
tab._lastOriginUuid = ev.uuid || tab._lastOriginUuid;
|
|
6069
|
+
for (const { view } of _bgCards) { if (view) tab.messagesEl?.appendChild(tab.bg.card(view)); }
|
|
6070
|
+
if (tab === activeTab()) scrollEnd();
|
|
6071
|
+
} else if (!_parentId && ev.origin && ev.origin.kind !== 'human') {
|
|
5949
6072
|
const from = describeOrigin(ev.origin);
|
|
5950
6073
|
if (from && tab._lastOriginUuid !== (ev.uuid || from)) {
|
|
5951
6074
|
tab._lastOriginUuid = ev.uuid || from;
|
|
@@ -6067,6 +6190,7 @@ function handleTabEvent(tab, ev) {
|
|
|
6067
6190
|
if (ev.session_id) {
|
|
6068
6191
|
if (!tab.sessionId) tab._freshSessionId = ev.session_id;
|
|
6069
6192
|
tab.sessionId = ev.session_id;
|
|
6193
|
+
_bgSessionSeen(tab);
|
|
6070
6194
|
if (tab.pendingLabel && !keepsNothing(tab)) {
|
|
6071
6195
|
storage.setItem(LABEL_PREFIX + ev.session_id, tab.pendingLabel);
|
|
6072
6196
|
tab.label = tab.pendingLabel;
|
|
@@ -9984,6 +10108,8 @@ function addToQueue(tab, text, images, files) {
|
|
|
9984
10108
|
}
|
|
9985
10109
|
|
|
9986
10110
|
function renderQueue(tab) {
|
|
10111
|
+
// The tray's auto-close keeps a tab while its queue holds prompts (_autoCloseKeep): said at every change.
|
|
10112
|
+
if (tab?.pillEl) markAutoCloseKeep(tab.pillEl, _autoCloseKeep(tab));
|
|
9987
10113
|
if (tab !== activeTab()) return;
|
|
9988
10114
|
const $tray = _panel?.querySelector('#cp-queue-tray');
|
|
9989
10115
|
const $items = $tray?.querySelector('.cp-queue-items');
|
|
@@ -11024,6 +11150,7 @@ function _closeCutOffTools(tab) {
|
|
|
11024
11150
|
if (task?.status === 'running') { task.status = 'stopped'; shells = true; }
|
|
11025
11151
|
}
|
|
11026
11152
|
if (shells) { try { renderBgTray(tab); } catch {} }
|
|
11153
|
+
try { tab.bg?.ended(); } catch {}
|
|
11027
11154
|
_setBackgroundWork(tab, []);
|
|
11028
11155
|
}
|
|
11029
11156
|
|
|
@@ -11033,6 +11160,7 @@ function _closeCutOffTools(tab) {
|
|
|
11033
11160
|
function _endRunBackgroundWork(tab) {
|
|
11034
11161
|
let changed = false;
|
|
11035
11162
|
try { changed = endRunningTasks(tab.tasks) > 0; } catch {}
|
|
11163
|
+
try { tab.bg?.ended(); } catch {}
|
|
11036
11164
|
let shells = false;
|
|
11037
11165
|
for (const task of tab.bgTasks?.values?.() || []) {
|
|
11038
11166
|
if (task?.status === 'running') { task.status = 'stopped'; shells = true; }
|
|
@@ -11833,6 +11961,7 @@ function wireEvents() {
|
|
|
11833
11961
|
for (const t of _tabs) if (!msg?.accountId || serverAccountId(t.accountId) === msg.accountId) void t.terminalAuthView?.refresh();
|
|
11834
11962
|
});
|
|
11835
11963
|
const $new = _panel.querySelector('.cp-new-btn');
|
|
11964
|
+
_panel.querySelector('#cp-bg-btn')?.addEventListener('click', () => { const tab = activeTab(); if (tab) _toggleBgView(tab); });
|
|
11836
11965
|
|
|
11837
11966
|
const $brand = _panel.querySelector('.cp-brand');
|
|
11838
11967
|
if ($brand) $brand.addEventListener('click', () => window.open('https://claude.ai/settings/usage', '_blank'));
|
|
@@ -294,9 +294,51 @@ async function routeLatest(runId) {
|
|
|
294
294
|
return false;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
/**
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
/**
|
|
298
|
+
* A run a tab still names and this window no longer follows, as the server has it: `over` when it
|
|
299
|
+
* ended or the server keeps it no more (its ledger never drops a live run), with its descriptor when
|
|
300
|
+
* there is one; null when the server did not say.
|
|
301
|
+
*/
|
|
302
|
+
async function readUnfollowedRun(runId) {
|
|
303
|
+
try {
|
|
304
|
+
const response = await fetch(`/api/sidepanel-runs/${encodeURIComponent(runId)}`);
|
|
305
|
+
if (response.status === 404) return { over: true, run: null };
|
|
306
|
+
if (!response.ok) return null;
|
|
307
|
+
const data = await response.json();
|
|
308
|
+
const run = descriptorFrom(data) || descriptorFrom(data?.run);
|
|
309
|
+
return run?.runId === runId ? { over: TERMINAL_STATUSES.has(run.status), run } : null;
|
|
310
|
+
} catch {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Tray timer: an unfinished task or a refused completion keeps its tab.
|
|
317
|
+
*
|
|
318
|
+
* A tab can name a run this window follows no more: the user continued the run's session by hand
|
|
319
|
+
* (OpenCode keeps the run on the tab, and the tab let the run go: 'native-loop:dismissed'), or a reload
|
|
320
|
+
* brought the tab back and not its run (reconcileRuns restores ended runs of the last day, ten at
|
|
321
|
+
* most). The server is asked about such a run: once it is over its tab is detached like any ended
|
|
322
|
+
* run's (the session and its transcript stay with the provider; nothing is stopped or deleted), and it
|
|
323
|
+
* stays while the run lives or the server did not answer. `provider` is the panel the tab is in, for a
|
|
324
|
+
* run the server keeps no more.
|
|
325
|
+
*/
|
|
326
|
+
export async function autoCloseNativeLoopTab(runId, provider = null) {
|
|
327
|
+
if (!runId) return;
|
|
328
|
+
let run = getNativeLoopRun(runId);
|
|
329
|
+
if (!run) {
|
|
330
|
+
const read = await readUnfollowedRun(runId);
|
|
331
|
+
// Followed again meanwhile (a reconcile attached it): decided below, like any run this window follows.
|
|
332
|
+
run = getNativeLoopRun(runId);
|
|
333
|
+
if (!run) {
|
|
334
|
+
const panel = read?.over ? (read.run?.provider || provider) : null;
|
|
335
|
+
if (!panel) return;
|
|
336
|
+
forgetWorkerEnd(runId);
|
|
337
|
+
window.dispatchEvent(new CustomEvent('native-loop:dismissed', { detail: { runId } }));
|
|
338
|
+
await detachProviderRun(runId, panel);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
300
342
|
if (!(await mayAutoCloseWorkerTab(run)) || _dismissed.has(runId)) return;
|
|
301
343
|
forgetWorkerEnd(runId);
|
|
302
344
|
window.dispatchEvent(new CustomEvent('native-loop:dismissed', { detail: { runId } }));
|
|
@@ -214,6 +214,27 @@ function _ensureToastContainer(position) {
|
|
|
214
214
|
return _toastContainer;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
function mountToast(container, toast) {
|
|
218
|
+
container.appendChild(toast);
|
|
219
|
+
requestAnimationFrame(() => requestAnimationFrame(() => toast.classList.add('visible')));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// An owner action that stays in the existing notification stack until dismissed or resolved.
|
|
223
|
+
export function showActionNotice({ title, action, closeLabel, onAction, onClose }) {
|
|
224
|
+
const toast = document.createElement('div');
|
|
225
|
+
toast.className = 'notif-toast'; toast.dataset.persistent = 'true';
|
|
226
|
+
toast.innerHTML = `<div class="notif-toast-accent"></div><div class="notif-toast-body">
|
|
227
|
+
<div class="notif-toast-provider" role="status"></div><button type="button" class="cli-detect-btn"></button>
|
|
228
|
+
</div><button type="button" class="notif-toast-close">×</button>`;
|
|
229
|
+
toast.querySelector('[role="status"]').textContent = title;
|
|
230
|
+
const button = toast.querySelector('.cli-detect-btn'); button.textContent = action;
|
|
231
|
+
button.addEventListener('click', onAction);
|
|
232
|
+
const close = toast.querySelector('.notif-toast-close'); close.setAttribute('aria-label', closeLabel);
|
|
233
|
+
close.addEventListener('click', onClose);
|
|
234
|
+
mountToast(_ensureToastContainer(getNotifSettings().toastPosition), toast);
|
|
235
|
+
return () => _dismissToast(toast);
|
|
236
|
+
}
|
|
237
|
+
|
|
217
238
|
function _showToast(type, title, body, source, opts) {
|
|
218
239
|
const s = getNotifSettings();
|
|
219
240
|
if (!s.toast) return;
|
|
@@ -254,16 +275,14 @@ function _showToast(type, title, body, source, opts) {
|
|
|
254
275
|
toast.querySelector('.notif-toast-close').addEventListener('click', () => _dismissToast(toast));
|
|
255
276
|
|
|
256
277
|
// Add to container
|
|
257
|
-
container
|
|
258
|
-
// Trigger animation
|
|
259
|
-
requestAnimationFrame(() => requestAnimationFrame(() => toast.classList.add('visible')));
|
|
278
|
+
mountToast(container, toast);
|
|
260
279
|
|
|
261
280
|
// Auto-dismiss
|
|
262
281
|
const dur = s.toastDuration * 1000;
|
|
263
282
|
toast._timeout = setTimeout(() => _dismissToast(toast), dur);
|
|
264
283
|
|
|
265
284
|
// Enforce max toasts
|
|
266
|
-
const toasts = container.querySelectorAll('.notif-toast');
|
|
285
|
+
const toasts = container.querySelectorAll('.notif-toast:not([data-persistent])');
|
|
267
286
|
if (toasts.length > MAX_TOASTS) {
|
|
268
287
|
_dismissToast(toasts[0]);
|
|
269
288
|
}
|
|
@@ -194,6 +194,10 @@ export function createStickyScrollController(container, options = {}) {
|
|
|
194
194
|
if (remaining > 0.5) scrollToBottom();
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
|
+
// Detached: only a scroll back down near the bottom follows again. An animated key or wheel scroll upward
|
|
198
|
+
// (WebKit's PageUp / ArrowUp) can step 1 px or less, under movedUp's 1 px; treating that step as "near the
|
|
199
|
+
// bottom" re-attached and the follow frame snapped the reader back, cancelling their scroll.
|
|
200
|
+
if (nextScrollTop < prevScrollTop) return;
|
|
197
201
|
if (refreshPosition()) scrollToBottom();
|
|
198
202
|
};
|
|
199
203
|
const onWheel = (event) => {
|
|
@@ -64,6 +64,12 @@ export function initSettings() {
|
|
|
64
64
|
// Launch: what Settings is built from, and its search index (the English names too), read and made once the
|
|
65
65
|
// page has painted, so the first open and the first search wait for nothing. The index needs the window's module:
|
|
66
66
|
// this step is what loads it in idle time.
|
|
67
|
+
registerLaunchPrefetch('browser-extension-update', async () => {
|
|
68
|
+
const [{ startExtensionUpdateNotices }, { showActionNotice }] = await Promise.all([
|
|
69
|
+
import('./browser-extension-updates.js'), import('./ui-notifications.js'),
|
|
70
|
+
]);
|
|
71
|
+
return startExtensionUpdateNotices({ tx: t, showNotice: showActionNotice });
|
|
72
|
+
}, { order: 59, owner: true });
|
|
67
73
|
registerLaunchPrefetch('settings-data', () => prefetchSettingsData(), { order: 60, owner: true });
|
|
68
74
|
registerLaunchPrefetch('settings-search-index', () => settingsModule.call('prebuildSettingsSearchIndex', []), { order: 62 });
|
|
69
75
|
// Changes other windows announce: the next open shows them.
|
|
@@ -15,6 +15,12 @@ const STATUS_MARKS = {
|
|
|
15
15
|
};
|
|
16
16
|
const initialized = new WeakSet();
|
|
17
17
|
|
|
18
|
+
// How many background tasks (shells, Monitors: the provider-independent registry, bg-tasks/bg-tasks-model.js) a
|
|
19
|
+
// pill's session still runs, written on the pill by the shared "⟳ N" badge (bg-tasks-view.js paintBgBadge). A turn
|
|
20
|
+
// that ended with work still running in the background is not done: its pill stays in Running until the last task
|
|
21
|
+
// ends, is stopped or expires.
|
|
22
|
+
export const BG_RUNNING_ATTR = 'data-bg-running';
|
|
23
|
+
|
|
18
24
|
export function trayColumnOf(el) {
|
|
19
25
|
if (el.classList.contains(GROUP)) {
|
|
20
26
|
let parent = el.previousElementSibling;
|
|
@@ -30,7 +36,8 @@ export function trayColumnOf(el) {
|
|
|
30
36
|
if (status === 'action' || badgeStatus === 'action' || classes.some(name => /-pill-(attention|waiting)$/.test(name))) {
|
|
31
37
|
return 'waiting';
|
|
32
38
|
}
|
|
33
|
-
if (status === 'working' || badgeStatus === 'working' || classes.some(name => name.endsWith('-pill-running'))
|
|
39
|
+
if (status === 'working' || badgeStatus === 'working' || classes.some(name => name.endsWith('-pill-running')) ||
|
|
40
|
+
Number(el.getAttribute?.(BG_RUNNING_ATTR)) > 0) {
|
|
34
41
|
return 'running';
|
|
35
42
|
}
|
|
36
43
|
return 'done';
|
|
@@ -364,7 +371,7 @@ export function initTrayColumns(tray, preferences = globalThis.localStorage) {
|
|
|
364
371
|
})) schedule();
|
|
365
372
|
}).observe(tray, {
|
|
366
373
|
childList: true, characterData: true, subtree: true, attributes: true, attributeOldValue: true,
|
|
367
|
-
attributeFilter: ['class', 'data-status', 'style', 'hidden'],
|
|
374
|
+
attributeFilter: ['class', 'data-status', 'style', 'hidden', BG_RUNNING_ATTR],
|
|
368
375
|
});
|
|
369
376
|
if (globalThis.ResizeObserver) {
|
|
370
377
|
const resize = new ResizeObserver(schedule);
|
|
@@ -97,6 +97,21 @@ export function isRunWorking(run, dispatch = null) {
|
|
|
97
97
|
return run?.turnState !== 'idle' && run?.turnState !== 'terminal';
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* The run's last turn was cut by a steer and the run goes on: it is marked steering, or its last turn ended with the
|
|
102
|
+
* reason 'steered' while the run itself has not ended. A run that ended after all (stopped, failed) is not this.
|
|
103
|
+
*/
|
|
104
|
+
export function wasSteered(run, dispatch = null) {
|
|
105
|
+
const ended = TERMINAL.has(String(dispatch?.state || ''))
|
|
106
|
+
|| (TERMINAL.has(String(run?.status || '')) && !(dispatch && run?.stoppedReason === 'steered'));
|
|
107
|
+
if (ended) return false;
|
|
108
|
+
const steered = (v) => !!v && typeof v === 'object' && (v.steering === true
|
|
109
|
+
|| [v.turnEndReason, v.endReason, v.lastTurn?.reason, v.lastResult?.reason, v.stoppedReason].includes('steered')
|
|
110
|
+
// The dispatcher's record of the cut turn (lib/assistant-dispatch.js: endReason 'steered', result null).
|
|
111
|
+
|| (Array.isArray(v.turns) && v.turns.length > 0 && v.turns[v.turns.length - 1]?.endReason === 'steered'));
|
|
112
|
+
return steered(dispatch) || steered(run);
|
|
113
|
+
}
|
|
114
|
+
|
|
100
115
|
/** The runtime descriptor says the run may have something to show: it ended, or it waits between turns. */
|
|
101
116
|
export function mayHaveEnded(run) {
|
|
102
117
|
return TERMINAL.has(String(run?.status || '')) || run?.turnState === 'idle';
|
|
@@ -204,6 +219,9 @@ export function workerEndView(run, dispatch = null, { t = fillWorkerEndCopy, bus
|
|
|
204
219
|
if (!run && !dispatch) return null;
|
|
205
220
|
if (!isDispatchedRun(run, dispatch)) return null;
|
|
206
221
|
if (isRunWorking(run, dispatch)) return null;
|
|
222
|
+
// A turn a steer cut (assistant/asst-steer.js): the steer's turn follows, so nothing ended. Never "Task complete"
|
|
223
|
+
// from the turn before it, never a failure.
|
|
224
|
+
if (wasSteered(run, dispatch)) return null;
|
|
207
225
|
|
|
208
226
|
const state = String(dispatch?.state || '');
|
|
209
227
|
const status = String(run?.status || '');
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Durable patch for node-pty's Windows ConPTY console-list helper
|
|
5
|
+
* (lib/conpty_console_list_agent.js).
|
|
6
|
+
*
|
|
7
|
+
* In node-pty 1.1.0, WindowsPtyAgent.kill() forks conpty_console_list_agent.js
|
|
8
|
+
* with inherited stderr. Line 13 calls getConsoleProcessList(shellPid) without
|
|
9
|
+
* a try/catch; during shutdown when the shell console is already gone, Windows
|
|
10
|
+
* returns AttachConsole failure, printing an uncaught exception stack trace to
|
|
11
|
+
* server logs and stalling kill() for 5 seconds until the parent's timeout
|
|
12
|
+
* falls back to [shellPid].
|
|
13
|
+
*
|
|
14
|
+
* Patching the helper makes it catch the error and immediately send [shellPid]
|
|
15
|
+
* back over IPC with zero stderr noise and zero 5 s delay.
|
|
16
|
+
*
|
|
17
|
+
* Applied automatically by:
|
|
18
|
+
* - neural-interface/scripts/rebuild-pty.js (postinstall for dev & npm i -g)
|
|
19
|
+
* - packaging/lib/stage.mjs prepareNatives() (packaged desktop builds)
|
|
20
|
+
* Verified by:
|
|
21
|
+
* - packaging/lib/verify.mjs auditBundle() (Windows bundles)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { createHash } from 'node:crypto';
|
|
25
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
26
|
+
import { dirname, join, resolve } from 'node:path';
|
|
27
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
28
|
+
|
|
29
|
+
export const PATCH_MARKER = '// synabun-patch: conpty-attach-console-fallback';
|
|
30
|
+
export const CONPTY_AGENT_REL = join('lib', 'conpty_console_list_agent.js');
|
|
31
|
+
|
|
32
|
+
// Exact SHA-256 of upstream node-pty@1.1.0 lib/conpty_console_list_agent.js (LF-normalized).
|
|
33
|
+
export const UPSTREAM_AGENT_SHA256 = '0d010879bb6680a0253d44363183d53e631f42972594eb6dcb1fb842c8c85e52';
|
|
34
|
+
|
|
35
|
+
const normalizeEol = (source) => String(source ?? '').replace(/\r\n/g, '\n');
|
|
36
|
+
const sha256 = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
|
|
37
|
+
|
|
38
|
+
export const PATCHED_AGENT_SOURCE = `"use strict";
|
|
39
|
+
${PATCH_MARKER}
|
|
40
|
+
/**
|
|
41
|
+
* Copyright (c) 2019, Microsoft Corporation (MIT License).
|
|
42
|
+
*
|
|
43
|
+
* This module fetches the console process list for a particular PID. It must be
|
|
44
|
+
* called from a different process (child_process.fork) as there can only be a
|
|
45
|
+
* single console attached to a process.
|
|
46
|
+
*
|
|
47
|
+
* Patched by SynaBun: catch AttachConsole failures during shutdown and fall
|
|
48
|
+
* back immediately to [shellPid] instead of crashing with stderr noise and
|
|
49
|
+
* waiting for the parent's 5 s timeout.
|
|
50
|
+
*/
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
var utils_1 = require("./utils");
|
|
53
|
+
var shellPid = parseInt(process.argv[2], 10);
|
|
54
|
+
var fallbackList = Number.isInteger(shellPid) && shellPid > 0 ? [shellPid] : [];
|
|
55
|
+
var consoleProcessList = fallbackList;
|
|
56
|
+
try {
|
|
57
|
+
var getConsoleProcessList = utils_1.loadNativeModule('conpty_console_list').module.getConsoleProcessList;
|
|
58
|
+
var list = getConsoleProcessList(shellPid);
|
|
59
|
+
if (Array.isArray(list)) {
|
|
60
|
+
consoleProcessList = list;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (_err) {
|
|
64
|
+
consoleProcessList = fallbackList;
|
|
65
|
+
}
|
|
66
|
+
if (typeof process.send === 'function') {
|
|
67
|
+
try {
|
|
68
|
+
process.send({ consoleProcessList: consoleProcessList }, function () {
|
|
69
|
+
process.exit(0);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (_err) {
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
process.exit(0);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=conpty_console_list_agent.js.map
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
export const PATCHED_AGENT_SHA256 = sha256(normalizeEol(PATCHED_AGENT_SOURCE));
|
|
83
|
+
|
|
84
|
+
/** True ONLY when `source` matches the exact patched SynaBun helper content (by SHA-256, never marker alone). */
|
|
85
|
+
export function isConptyConsoleListPatched(source) {
|
|
86
|
+
return typeof source === 'string' && sha256(normalizeEol(source)) === PATCHED_AGENT_SHA256;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Transform upstream node-pty 1.1.0 conpty_console_list_agent.js by exact SHA-256 hash.
|
|
91
|
+
* Refuses any unrecognized or modified content with a clear reason.
|
|
92
|
+
* Returns { status: 'patched' | 'already-patched' | 'unmatched', changed, content, reason? }.
|
|
93
|
+
*/
|
|
94
|
+
export function applyConptyConsoleListPatch(source) {
|
|
95
|
+
const text = String(source ?? '');
|
|
96
|
+
const hash = sha256(normalizeEol(text));
|
|
97
|
+
if (hash === PATCHED_AGENT_SHA256) {
|
|
98
|
+
return { status: 'already-patched', changed: false, content: text };
|
|
99
|
+
}
|
|
100
|
+
if (hash === UPSTREAM_AGENT_SHA256) {
|
|
101
|
+
return { status: 'patched', changed: true, content: PATCHED_AGENT_SOURCE };
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
status: 'unmatched',
|
|
105
|
+
changed: false,
|
|
106
|
+
content: text,
|
|
107
|
+
reason: `conpty_console_list_agent.js sha256 ${hash} matches neither known upstream node-pty 1.1.0 (${UPSTREAM_AGENT_SHA256}) nor exact SynaBun patched helper (${PATCHED_AGENT_SHA256}); refusing to overwrite`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Patch `lib/conpty_console_list_agent.js` inside a single `node-pty` package directory.
|
|
113
|
+
* Idempotent; refuses unknown content without overwriting.
|
|
114
|
+
*/
|
|
115
|
+
export function patchNodePtyDir(ptyDir, { log = () => {} } = {}) {
|
|
116
|
+
const target = join(ptyDir, CONPTY_AGENT_REL);
|
|
117
|
+
if (!existsSync(target)) {
|
|
118
|
+
return { status: 'missing', path: target, reason: `missing ${target}` };
|
|
119
|
+
}
|
|
120
|
+
const source = readFileSync(target, 'utf8');
|
|
121
|
+
const result = applyConptyConsoleListPatch(source);
|
|
122
|
+
if (result.changed) {
|
|
123
|
+
writeFileSync(target, result.content, 'utf8');
|
|
124
|
+
log(`[patch-node-pty] patched ${target} (AttachConsole fallback)`);
|
|
125
|
+
}
|
|
126
|
+
return { status: result.status, path: target, ...(result.reason ? { reason: result.reason } : {}) };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const isMain = process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href;
|
|
130
|
+
if (isMain) {
|
|
131
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
132
|
+
const neuralRoot = resolve(__dirname, '..');
|
|
133
|
+
const packageRoot = resolve(neuralRoot, '..');
|
|
134
|
+
const args = process.argv.slice(2);
|
|
135
|
+
const dirs = args.length
|
|
136
|
+
? args.map(dir => resolve(dir))
|
|
137
|
+
: [...new Set([
|
|
138
|
+
resolve(neuralRoot, 'node_modules', 'node-pty'),
|
|
139
|
+
resolve(packageRoot, 'node_modules', 'node-pty'),
|
|
140
|
+
])];
|
|
141
|
+
let unmatched = false;
|
|
142
|
+
for (const dir of dirs) {
|
|
143
|
+
const res = patchNodePtyDir(dir, { log: console.log });
|
|
144
|
+
if (res.status === 'already-patched') console.log(`[patch-node-pty] already patched: ${res.path}`);
|
|
145
|
+
else if (res.status === 'unmatched') {
|
|
146
|
+
console.warn(`[patch-node-pty] ${res.reason || `unexpected contents, skipped: ${res.path}`}`);
|
|
147
|
+
unmatched = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (unmatched) process.exitCode = 1;
|
|
151
|
+
}
|
|
@@ -17,6 +17,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
17
17
|
import { ensureVendoredExecutables } from '../lib/native-binary-runtime.js';
|
|
18
18
|
import { pruneExternalTools } from '../../lib/external-tools.js';
|
|
19
19
|
import { findInstalled } from '../../lib/runtime-dependencies.js';
|
|
20
|
+
import { patchNodePtyDir } from './patch-node-pty.mjs';
|
|
20
21
|
|
|
21
22
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
23
|
const neuralRoot = resolve(__dirname, '..');
|
|
@@ -70,6 +71,15 @@ if (!existsSync(ptyDir)) {
|
|
|
70
71
|
process.exit(0);
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
// Step 1a-bis: Apply SynaBun's Windows ConPTY AttachConsole fallback patch so
|
|
75
|
+
// shutdown never prints uncaught AttachConsole stack traces or stalls 5 s.
|
|
76
|
+
for (const candidate of new Set([ptyDir, resolve(neuralRoot, 'node_modules', 'node-pty'), resolve(packageRoot, 'node_modules', 'node-pty')])) {
|
|
77
|
+
const patched = patchNodePtyDir(candidate, { log: console.log });
|
|
78
|
+
if (patched.status === 'unmatched') {
|
|
79
|
+
console.warn(`[rebuild-pty] ${patched.reason || `node-pty conpty helper had unexpected contents: ${patched.path}`}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
// Step 1b: Check if node-pty actually works (spawn test, not just module load)
|
|
74
84
|
try {
|
|
75
85
|
const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';
|