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
|
@@ -87,9 +87,11 @@ function attachmentNode(file) {
|
|
|
87
87
|
* helpers:
|
|
88
88
|
* contentBlocks(output) → a node for MCP content blocks, or null
|
|
89
89
|
* onOpenChild(sessionId) → open the sub-agent session of a task card
|
|
90
|
+
* shell → the shell command of a bash call, as the panel knows it live
|
|
91
|
+
* terminal(shellId) → the node that shows that command's output as it is printed
|
|
90
92
|
*/
|
|
91
93
|
export function renderToolCard(part, helpers = {}) {
|
|
92
|
-
const view = toolCardView(part);
|
|
94
|
+
const view = toolCardView(part, { shell: helpers.shell || null, live: typeof helpers.terminal === 'function' });
|
|
93
95
|
const callId = part.callID || part.id || `${view.tool}-${part.messageID || ''}`;
|
|
94
96
|
const expanded = _expandedByUser.has(callId) ? _expandedByUser.get(callId) : view.defaultExpanded;
|
|
95
97
|
|
|
@@ -119,6 +121,8 @@ export function renderToolCard(part, helpers = {}) {
|
|
|
119
121
|
const next = !wrap.classList.contains('ocpv2-tool-expanded');
|
|
120
122
|
_expandedByUser.set(callId, next);
|
|
121
123
|
wrap.classList.toggle('ocpv2-tool-expanded', next);
|
|
124
|
+
// A terminal block has a size only once its card is open.
|
|
125
|
+
if (next) for (const term of wrap.querySelectorAll('.ocpv2-term')) term.dispatchEvent(new Event('ocpv2-term-show'));
|
|
122
126
|
});
|
|
123
127
|
wrap.appendChild(head);
|
|
124
128
|
|
|
@@ -126,6 +130,8 @@ export function renderToolCard(part, helpers = {}) {
|
|
|
126
130
|
for (const section of view.sections) {
|
|
127
131
|
if (section.kind === 'code') {
|
|
128
132
|
body.appendChild(el('div', 'ocpv2-tool-input', section.prompt ? `${section.prompt} ${section.text}` : section.text));
|
|
133
|
+
} else if (section.kind === 'terminal') {
|
|
134
|
+
body.appendChild(helpers.terminal(section.shellId));
|
|
129
135
|
} else if (section.kind === 'output') {
|
|
130
136
|
body.appendChild(outputSection(section, helpers));
|
|
131
137
|
} else if (section.kind === 'diff') {
|
|
@@ -718,10 +718,12 @@ async function settleAsk(eventType, sessionId, requestId, response) {
|
|
|
718
718
|
return result;
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
-
|
|
721
|
+
// `force`: "Stop anyway" (offered after a second Stop that could not end a command): the turn ends even while that
|
|
722
|
+
// command may still run. A server from before it ignores the flag (a plain Stop).
|
|
723
|
+
async function abortSession(sessionId, { force = false } = {}) {
|
|
722
724
|
const pending = _asks.openAsksOf(sessionId);
|
|
723
725
|
const stored = storedAsks((owner) => owner === sessionId || knownDescendant(owner, sessionId, _parentOf));
|
|
724
|
-
const result = await request({ type: 'message:abort', sessionId });
|
|
726
|
+
const result = await request({ type: 'message:abort', sessionId, ...(force ? { force: true } : {}) });
|
|
725
727
|
if (!replyFailed(result)) {
|
|
726
728
|
// Stop can finish after a new turn has started. Clear only the requests seen when Stop was pressed.
|
|
727
729
|
for (const ask of pending) _asks.note(`${ask.kind}.replied`, { requestID: ask.id, sessionID: ask.owner });
|
|
@@ -766,6 +768,9 @@ export const api = {
|
|
|
766
768
|
sessionStatus: ({ sessionId, cwd } = {}) => gated({ type: 'session:status', sessionId, cwd }),
|
|
767
769
|
permissionList: ({ sessionId, cwd } = {}) => gated({ type: 'permission:list', sessionId, cwd }),
|
|
768
770
|
sessionTodo: ({ sessionId, cwd } = {}) => gated({ type: 'session:todo', sessionId, cwd }),
|
|
771
|
+
// The shell commands of the session's tool calls, and a page of what one printed (ocp-v2-shell-logic.js).
|
|
772
|
+
shellList: ({ sessionId, cwd } = {}) => gated({ type: 'shell:list', sessionId, cwd }),
|
|
773
|
+
shellOutput: ({ sessionId, shellId, cwd, cursor, tail, limit } = {}) => gated({ type: 'shell:output', sessionId, shellId, cwd, cursor, tail, limit }),
|
|
769
774
|
sessionRevert: ({ sessionId, messageID, partID, cwd } = {}) => gated({ type: 'session:revert', sessionId, messageID, partID, cwd }),
|
|
770
775
|
sessionUnrevert: ({ sessionId, cwd } = {}) => gated({ type: 'session:unrevert', sessionId, cwd }),
|
|
771
776
|
sessionFork: ({ sessionId, messageID, cwd } = {}) => gated({ type: 'session:fork', sessionId, messageID, cwd }),
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
// The dropdown is the app's .cc-dropdown (Settings wires every .stg-dropdown, wireStgDropdowns); a server from before
|
|
15
15
|
// the mode existed reports no `fullControl` and the section stays hidden. Disconnect and Revoke pairing are confirmed
|
|
16
16
|
// too; Take back is immediate and never closes the tab.
|
|
17
|
+
import { beginExtensionUpdateRead } from '../browser-extension-updates.js';
|
|
18
|
+
import { extensionUpdateHTML, wireExtensionUpdate } from './settings-extension-update.js';
|
|
19
|
+
|
|
17
20
|
const SYMBOL = {
|
|
18
21
|
ok: '<path d="m5 12 4 4 10-10"></path>',
|
|
19
22
|
warn: '<path d="M9 5v14M15 5v14"></path>',
|
|
@@ -29,7 +32,7 @@ export function extensionSettingsHTML(kit) {
|
|
|
29
32
|
const button = (action, key, extra = '') => `<button type="button" class="cli-detect-btn" data-extension-action="${action}"${extra}>${t(key)}</button>`;
|
|
30
33
|
const modes = [['full', t('modeFull')], ['restricted', t('modeRestricted')]];
|
|
31
34
|
const symbols = Object.entries(SYMBOL).map(([name, path]) => `<svg class="bc-ext-sym" data-sym="${name}" viewBox="0 0 24 24">${path}</svg>`).join('');
|
|
32
|
-
return
|
|
35
|
+
return `${extensionUpdateHTML(kit)}<div class="stg-field bc-extension" id="bc-extension" data-card-state="loading" hidden>
|
|
33
36
|
<div class="bc-ext-head" id="bc-extension-head" data-tone="">
|
|
34
37
|
<div class="bc-ext-status-row">
|
|
35
38
|
<span class="bc-ext-symbol" aria-hidden="true">${symbols}</span>
|
|
@@ -37,6 +40,7 @@ export function extensionSettingsHTML(kit) {
|
|
|
37
40
|
<span class="stg-badge bc-ext-status" id="bc-extension-status" role="status" aria-live="polite" aria-labelledby="bc-extension-status-label"></span>
|
|
38
41
|
</div>
|
|
39
42
|
<p class="stg-help bc-ext-text bc-ext-status-help" id="bc-extension-status-help"></p>
|
|
43
|
+
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-moved" hidden>${c('movedHelp')}</p>
|
|
40
44
|
<div class="bc-inline-group bc-ext-actions" id="bc-extension-status-actions" hidden>
|
|
41
45
|
<button type="button" class="cli-detect-btn bc-ext-primary" data-extension-action="resume">${c('reconnect')}</button>
|
|
42
46
|
<button type="button" class="cli-detect-btn" data-extension-action="retry" hidden>${c('retry')}</button>
|
|
@@ -71,7 +75,14 @@ export function extensionSettingsHTML(kit) {
|
|
|
71
75
|
<p class="stg-help bc-ext-text" id="bc-extension-setup-status" role="status" aria-live="polite"></p>
|
|
72
76
|
<div class="bc-inline-group bc-ext-actions" id="bc-extension-setup-alternatives" hidden></div>
|
|
73
77
|
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-setup-default">${c('setupDefault')}</p>
|
|
74
|
-
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-reload" data-tone="warn" hidden>${t('reloadNeeded')}</p>
|
|
78
|
+
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-reload" data-tone="warn" data-reload-text="${t('reloadNeeded')}" data-repaired-text="${t('reloadRepaired')}" hidden>${t('reloadNeeded')}</p>
|
|
79
|
+
<div class="bc-inline-group bc-ext-actions" id="bc-extension-reload-actions" hidden>
|
|
80
|
+
<button type="button" class="cli-detect-btn" data-extension-action="reload-confirm">${c('reloadConfirm')}</button>
|
|
81
|
+
</div>
|
|
82
|
+
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-update" data-tone="warn" role="status" data-updating-text="${c('updating')}" data-failed-text="${c('updateFailed')}" hidden></p>
|
|
83
|
+
<div class="bc-inline-group bc-ext-actions" id="bc-extension-update-actions" hidden>
|
|
84
|
+
<button type="button" class="cli-detect-btn" data-extension-action="update">${c('retry')}</button>
|
|
85
|
+
</div>
|
|
75
86
|
</section>
|
|
76
87
|
<details class="stg-advanced bc-ext-advanced" id="bc-extension-files" data-extension-section="files">
|
|
77
88
|
<summary>${CHEVRON}<span>${c('advanced')}</span></summary>
|
|
@@ -90,7 +101,7 @@ export function extensionSettingsHTML(kit) {
|
|
|
90
101
|
<p class="stg-help bc-ext-text">${t('install')}</p>
|
|
91
102
|
<label class="bc-ext-label" for="bc-extension-folder">${t('folder')}</label>
|
|
92
103
|
<div class="bc-ext-control-row">
|
|
93
|
-
<input class="browser-cfg-input bc-ext-path" id="bc-extension-folder" readonly spellcheck="false" autocomplete="off">
|
|
104
|
+
<input class="browser-cfg-input bc-ext-path" id="bc-extension-folder" readonly spellcheck="false" autocomplete="off" placeholder="${c('folderPending')}">
|
|
94
105
|
<div class="bc-inline-group bc-ext-actions">${button('copy', 'copy')}${button('refresh', 'refresh')}</div>
|
|
95
106
|
</div>
|
|
96
107
|
</section>
|
|
@@ -130,6 +141,7 @@ export function cardState(data, setup = null, { failed = false, launching = fals
|
|
|
130
141
|
const running = setup?.state || data?.setup;
|
|
131
142
|
if (launching) return 'launching';
|
|
132
143
|
if (data?.connected) return failed ? 'error' : 'connected';
|
|
144
|
+
if (running === 'downloading') return 'downloading';
|
|
133
145
|
if (running === 'waiting-for-extension') return 'setup';
|
|
134
146
|
if (running === 'pairing') return 'pairing';
|
|
135
147
|
if (running === 'unsupported') return 'unsupported';
|
|
@@ -137,6 +149,22 @@ export function cardState(data, setup = null, { failed = false, launching = fals
|
|
|
137
149
|
if (data?.paired) return 'disconnected';
|
|
138
150
|
return 'unpaired';
|
|
139
151
|
}
|
|
152
|
+
/** The setup's download errors (lib/browser-extension-setup.js DOWNLOAD_ERRORS): each has its own sentence, and Try again. */
|
|
153
|
+
export const DOWNLOAD_ERRORS = Object.freeze(['EXTENSION_DOWNLOAD_OFFLINE', 'EXTENSION_DOWNLOAD_UNAVAILABLE', 'EXTENSION_VERIFY_FAILED']);
|
|
154
|
+
/** How far a download is, 0 to 100 (0 while the size is not known). */
|
|
155
|
+
export function downloadPercent(download) {
|
|
156
|
+
const total = Number(download?.total) || 0, received = Number(download?.received) || 0;
|
|
157
|
+
return total > 0 ? Math.max(0, Math.min(100, Math.floor(received / total * 100))) : 0;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* What the card says about the folder's own update (a folder older than this release's extension, which SynaBun
|
|
161
|
+
* downloads by itself): 'updating' while it is on its way or about to be, 'failed' when it did not arrive, else null.
|
|
162
|
+
*/
|
|
163
|
+
export function updateNote(data) {
|
|
164
|
+
const pkg = data?.package;
|
|
165
|
+
if (!pkg || pkg.needs !== 'update') return null;
|
|
166
|
+
return pkg.phase === 'failed' ? 'failed' : 'updating';
|
|
167
|
+
}
|
|
140
168
|
/** Host and path of an address: the query and fragment (sign-in challenges, tokens) are never shown. */
|
|
141
169
|
export function shownAddress(url) {
|
|
142
170
|
let u;
|
|
@@ -161,7 +189,7 @@ export function groupByAgent(tabs = []) {
|
|
|
161
189
|
const STATUS_TONES = ['stg-badge-ok', 'stg-badge-warn', 'stg-badge-err'];
|
|
162
190
|
const HEAD = {
|
|
163
191
|
connected: ['ok', 'connectedHelp'], disconnected: ['warn', 'disconnectedHelp'], unpaired: ['off', 'unpairedHelp'],
|
|
164
|
-
launching: ['sync', 'launchingHelp'], setup: ['sync', 'setupRunningHelp'], pairing: ['sync', 'pairingHelp'],
|
|
192
|
+
launching: ['sync', 'launchingHelp'], downloading: ['sync', 'downloadingHelp'], setup: ['sync', 'setupRunningHelp'], pairing: ['sync', 'pairingHelp'],
|
|
165
193
|
unsupported: ['err', 'unsupportedHelp'], error: ['err', 'errorHelp'],
|
|
166
194
|
};
|
|
167
195
|
const CONFIRMS = {
|
|
@@ -172,6 +200,7 @@ const CONFIRMS = {
|
|
|
172
200
|
};
|
|
173
201
|
|
|
174
202
|
export function wireExtensionSettings(root, { tx, signal }) {
|
|
203
|
+
wireExtensionUpdate(root, { tx, signal });
|
|
175
204
|
const pane = root.querySelector('#bc-extension'); if (!pane) return;
|
|
176
205
|
const t = (key, params) => tx(`browserExtension.${key}`, params);
|
|
177
206
|
const c = (key, params) => tx(`browserExtension.card.${key}`, params);
|
|
@@ -288,24 +317,26 @@ export function wireExtensionSettings(root, { tx, signal }) {
|
|
|
288
317
|
if (section.hidden) return;
|
|
289
318
|
const running = setup?.state || data.setup;
|
|
290
319
|
section.dataset.state = running;
|
|
291
|
-
const again = !!data.paired && !['setup', 'pairing', 'unsupported', 'launching'].includes(state);
|
|
320
|
+
const again = !!data.paired && !['setup', 'pairing', 'unsupported', 'launching', 'downloading'].includes(state);
|
|
292
321
|
section.dataset.mode = again ? 'again' : 'connect';
|
|
293
322
|
const title = query('setup-title'), help = query('setup-help');
|
|
294
323
|
title.textContent = again ? title.dataset.againText : title.dataset.connectText;
|
|
295
324
|
help.textContent = again ? help.dataset.againText : help.dataset.connectText;
|
|
296
325
|
const start = query('setup-start');
|
|
297
|
-
|
|
326
|
+
// A download that failed is tried again by the same button, under its own words.
|
|
327
|
+
const downloadFailed = running === 'error' && DOWNLOAD_ERRORS.includes(setup?.code);
|
|
328
|
+
start.textContent = downloadFailed ? c('retry') : data.connected ? start.dataset.reinstallText : data.paired ? start.dataset.reconnectText : start.dataset.connectText;
|
|
298
329
|
start.classList.toggle('bc-ext-primary', !data.paired);
|
|
299
330
|
start.disabled = launching;
|
|
300
331
|
const active = !['idle', 'connected'].includes(running);
|
|
301
|
-
start.hidden = ['waiting-for-extension', 'pairing'].includes(running);
|
|
332
|
+
start.hidden = ['downloading', 'waiting-for-extension', 'pairing'].includes(running);
|
|
302
333
|
query('setup-cancel').hidden = !active;
|
|
303
334
|
query('setup-reopen').hidden = running !== 'waiting-for-extension';
|
|
304
335
|
query('setup-default').hidden = again || active;
|
|
305
336
|
const name = setup?.browser?.name || '';
|
|
306
|
-
const known = ['waiting-for-extension', 'pairing', 'connected', 'unsupported'].includes(running);
|
|
307
|
-
query('setup-status').textContent = launching ? c('launching') : running === 'idle' ? '' : known ? tx(`browserExtension.setup.settings_${running.replace(/-/g, '_')}`, { browser: name })
|
|
308
|
-
: tx('browserExtension.setup.settings_error', { code: setup?.code || '' });
|
|
337
|
+
const known = ['downloading', 'waiting-for-extension', 'pairing', 'connected', 'unsupported'].includes(running);
|
|
338
|
+
query('setup-status').textContent = launching ? c('launching') : running === 'idle' ? '' : known ? tx(`browserExtension.setup.settings_${running.replace(/-/g, '_')}`, { browser: name, percent: downloadPercent(setup?.download) })
|
|
339
|
+
: downloadFailed ? tx(`browserExtension.setup.error${setup.code}`) : tx('browserExtension.setup.settings_error', { code: setup?.code || '' });
|
|
309
340
|
const alternatives = query('setup-alternatives'); alternatives.replaceChildren();
|
|
310
341
|
const others = running === 'unsupported' ? (setup?.installedBrowsers || []).filter(b => b?.supported && b.id !== setup?.browser?.id) : [];
|
|
311
342
|
for (const browser of others) {
|
|
@@ -314,7 +345,19 @@ export function wireExtensionSettings(root, { tx, signal }) {
|
|
|
314
345
|
alternatives.append(option);
|
|
315
346
|
}
|
|
316
347
|
alternatives.hidden = !others.length;
|
|
317
|
-
|
|
348
|
+
// The browser's Reload: for an older copy or a port change, or in a repair's own words (files that were not the
|
|
349
|
+
// extension were replaced, and the browser may still run them). Said until the setup page sees the extension (a port change) or
|
|
350
|
+
// the owner confirms the Reload below (a repair).
|
|
351
|
+
const reload = query('reload'), reloadText = data.reloadRepaired === true ? reload.dataset.repairedText : reload.dataset.reloadText;
|
|
352
|
+
reload.hidden = !!data.update || !(data.reloadNeeded === true);
|
|
353
|
+
if (reloadText && reload.textContent !== reloadText) reload.textContent = reloadText;
|
|
354
|
+
// A repair's Reload ends only by the owner's click here (POST reload/confirm): the copy the browser still runs
|
|
355
|
+
// would answer the setup page just the same, so nothing it says, nor any refresh of this card, clears it.
|
|
356
|
+
query('reload-actions').hidden = !!data.update || !(data.reloadNeeded === true && data.reloadRepaired === true);
|
|
357
|
+
// The folder's own update (never while a setup shows its own download): on its way, or failed with Try again.
|
|
358
|
+
const update = active || data.update ? null : updateNote(data), note = query('update');
|
|
359
|
+
note.hidden = !update; note.textContent = update ? (update === 'failed' ? note.dataset.failedText : note.dataset.updatingText) : '';
|
|
360
|
+
query('update-actions').hidden = update !== 'failed';
|
|
318
361
|
}
|
|
319
362
|
// The status at the top: a symbol, the word (Settings' badge), what it means, the one action that helps.
|
|
320
363
|
function showHead(state, data, error) {
|
|
@@ -325,13 +368,15 @@ export function wireExtensionSettings(root, { tx, signal }) {
|
|
|
325
368
|
if (error) setStatus(`${t('restart')} ${error}`, 'err');
|
|
326
369
|
else if (state === 'connected') setStatus(`${t('connected')}${modeWord}`, 'ok');
|
|
327
370
|
else if (state === 'disconnected') setStatus(`${t('disconnected')}${modeWord}`, 'warn');
|
|
328
|
-
else if (['setup', 'pairing', 'launching'].includes(state)) setStatus(c(state === 'setup' ? 'setupRunningTitle' : state, { browser: lastSetup?.browser?.name || '' }));
|
|
371
|
+
else if (['setup', 'pairing', 'launching', 'downloading'].includes(state)) setStatus(c(state === 'setup' ? 'setupRunningTitle' : state, { browser: lastSetup?.browser?.name || '' }));
|
|
329
372
|
else if (state === 'unsupported') setStatus(c('unsupported'));
|
|
330
373
|
else setStatus(t('unpaired'));
|
|
331
374
|
query('status-help').textContent = c(help, { browser: lastSetup?.browser?.name || '' });
|
|
332
375
|
const actions = query('status-actions');
|
|
333
376
|
const resume = actions.querySelector('[data-extension-action="resume"]'), retry = actions.querySelector('[data-extension-action="retry"]');
|
|
334
377
|
resume.hidden = state !== 'disconnected'; retry.hidden = !error;
|
|
378
|
+
// Paired, and the browser stays away: the extension may have been loaded from the old folder inside the app.
|
|
379
|
+
query('moved').hidden = !(state === 'disconnected' && !error);
|
|
335
380
|
actions.hidden = resume.hidden && retry.hidden;
|
|
336
381
|
query('footer').hidden = !data?.paired;
|
|
337
382
|
query('files').hidden = !data?.paired;
|
|
@@ -354,10 +399,12 @@ export function wireExtensionSettings(root, { tx, signal }) {
|
|
|
354
399
|
showTabs(data, connected && !error);
|
|
355
400
|
}
|
|
356
401
|
async function refresh() {
|
|
402
|
+
const accept = beginExtensionUpdateRead();
|
|
357
403
|
const data = await api();
|
|
358
404
|
let setup = null;
|
|
359
405
|
if (typeof data.setup === 'string' && data.setup !== 'idle') { try { setup = await api('setup/status'); } catch { setup = null; } }
|
|
360
406
|
last = data; lastSetup = setup;
|
|
407
|
+
if (!signal.aborted) accept(data.update || null);
|
|
361
408
|
render();
|
|
362
409
|
}
|
|
363
410
|
async function takeBack(handle) {
|
|
@@ -397,13 +444,14 @@ export function wireExtensionSettings(root, { tx, signal }) {
|
|
|
397
444
|
if (busy) { if (action === 'mode') queuedMode = body; return; }
|
|
398
445
|
busy = true;
|
|
399
446
|
try {
|
|
400
|
-
if (action === 'copy') { await navigator.clipboard.writeText(folder); }
|
|
447
|
+
if (action === 'copy') { if (folder) await navigator.clipboard.writeText(folder); }
|
|
401
448
|
else if (action === 'setup-start' || action === 'setup-open-in') {
|
|
402
449
|
launching = true; render();
|
|
403
450
|
try { await api('setup/start', action === 'setup-open-in' ? { browser: body?.browser } : {}); } finally { launching = false; }
|
|
404
451
|
}
|
|
405
452
|
else if (action === 'setup-cancel') await api('setup/cancel', {});
|
|
406
453
|
else if (action === 'setup-reopen') await api('setup/reopen', {});
|
|
454
|
+
else if (action === 'reload-confirm') await api('reload/confirm', { reloaded: true });
|
|
407
455
|
else if (!['refresh', 'retry'].includes(action)) {
|
|
408
456
|
const data = await api(action, body || (action === 'pair' ? { port: Number(query('port').value) } : {}));
|
|
409
457
|
if (action !== 'mode') showCode(action === 'pair' ? data.code : null);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { acceptExtensionUpdate, refreshExtensionUpdate, watchExtensionUpdate } from '../browser-extension-updates.js';
|
|
2
|
+
import { extensionUpdateView } from '../extension-update-view.js';
|
|
3
|
+
|
|
4
|
+
// A sibling of the connection controls so an installed extension can be updated in any browser mode.
|
|
5
|
+
export function extensionUpdateHTML(kit) {
|
|
6
|
+
const t = key => kit.te(`browserExtension.updateFlow.${key}`);
|
|
7
|
+
const button = (id, key, primary = false) => `<button type="button" class="cli-detect-btn${primary ? ' bc-ext-primary' : ''}" data-update-action="${id}">${t(key)}</button>`;
|
|
8
|
+
return `<section class="stg-field bc-extension" id="bc-extension-update-flow" aria-labelledby="bc-update-title" hidden>
|
|
9
|
+
<div class="bc-ext-part">
|
|
10
|
+
<h4 class="stg-subhead" id="bc-update-title" tabindex="-1"></h4>
|
|
11
|
+
<p class="stg-help bc-ext-text" id="bc-update-notes" hidden></p>
|
|
12
|
+
<p class="stg-help bc-ext-text" id="bc-update-status" role="status"></p>
|
|
13
|
+
<progress id="bc-update-progress" max="100" aria-labelledby="bc-update-status" hidden></progress>
|
|
14
|
+
<div class="bc-inline-group bc-ext-actions" id="bc-update-actions" hidden>
|
|
15
|
+
${button('reload', 'now', true)}${button('retry', 'retry')}${button('guide', 'showSteps')}
|
|
16
|
+
</div>
|
|
17
|
+
<div class="bc-ext-confirm" id="bc-update-warning" role="group" aria-labelledby="bc-update-warning-title" hidden>
|
|
18
|
+
<p id="bc-update-warning-title" class="stg-help bc-ext-text">${t('busy')}</p>
|
|
19
|
+
<div class="bc-inline-group bc-ext-actions">${button('wait', 'wait')}${button('continue', 'goAhead')}</div>
|
|
20
|
+
</div>
|
|
21
|
+
<ol class="stg-help" id="bc-update-guide" hidden>
|
|
22
|
+
<li>${t('stepOpen')}
|
|
23
|
+
<div class="bc-inline-group bc-ext-actions">${button('chrome', 'copyChrome')}${button('edge', 'copyEdge')}</div>
|
|
24
|
+
</li>
|
|
25
|
+
<li>${t('stepReload')}</li><li id="bc-update-detect"></li>
|
|
26
|
+
</ol>
|
|
27
|
+
<div class="bc-inline-group bc-ext-actions" id="bc-update-verify" hidden>
|
|
28
|
+
${button('confirm', 'confirm')}<a class="cli-detect-btn" href="/extension-setup" target="_blank" rel="noopener">${t('checkPort')}</a>
|
|
29
|
+
</div>
|
|
30
|
+
<p class="stg-help bc-ext-text" id="bc-update-feedback" role="status" hidden></p>
|
|
31
|
+
</div>
|
|
32
|
+
</section>`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function wireExtensionUpdate(root, { tx, signal }) {
|
|
36
|
+
const panel = root.querySelector('#bc-extension-update-flow');
|
|
37
|
+
if (!panel) return;
|
|
38
|
+
const find = id => panel.querySelector(`#bc-update-${id}`);
|
|
39
|
+
const action = name => panel.querySelector(`[data-update-action="${name}"]`);
|
|
40
|
+
const t = (key, params) => tx(`browserExtension.updateFlow.${key}`, params);
|
|
41
|
+
const put = (node, text) => { if (node.textContent !== text) node.textContent = text; };
|
|
42
|
+
let update, view, warning = null, allowGuide = false, posting = false;
|
|
43
|
+
function feedback(text) { find('feedback').hidden = !text; put(find('feedback'), text); }
|
|
44
|
+
function render(next) {
|
|
45
|
+
const previouslyBusy = update?.confirmBusy;
|
|
46
|
+
const model = extensionUpdateView(next, tx);
|
|
47
|
+
if (model?.key !== view?.key || model?.guided !== view?.guided || !model?.due) {
|
|
48
|
+
warning = null; allowGuide = false; feedback('');
|
|
49
|
+
}
|
|
50
|
+
update = next; view = model; panel.hidden = !view;
|
|
51
|
+
if (!view) return;
|
|
52
|
+
put(find('title'), view.title); put(find('status'), view.message);
|
|
53
|
+
put(find('notes'), view.notes); find('notes').hidden = !view.notes;
|
|
54
|
+
find('status').hidden = !view.message;
|
|
55
|
+
const progress = find('progress');
|
|
56
|
+
progress.hidden = update.phase !== 'downloading' || !!update.pending; if (!progress.hidden) progress.value = update.percent;
|
|
57
|
+
if (!view.updateNow && !view.guided) warning = null;
|
|
58
|
+
if (next.confirmBusy && view.updateNow && !previouslyBusy) warning = 'reload';
|
|
59
|
+
const warnGuide = view.guided && view.busy && !allowGuide;
|
|
60
|
+
action('guide').hidden = !warnGuide;
|
|
61
|
+
action('reload').hidden = !view.updateNow; action('retry').hidden = !view.retry && !view.download;
|
|
62
|
+
put(action('retry'), t(view.download ? 'download' : 'retry'));
|
|
63
|
+
find('actions').hidden = !!warning || !(view.updateNow || view.retry || view.download || warnGuide);
|
|
64
|
+
find('warning').hidden = !warning;
|
|
65
|
+
put(action('continue'), t(warning === 'guide' ? 'showSteps' : 'goAhead'));
|
|
66
|
+
find('guide').hidden = !view.guided || warnGuide;
|
|
67
|
+
put(find('detect'), t(view.confirmRepair ? 'stepConfirm' : view.checkPort ? 'stepPort' : 'stepDetect'));
|
|
68
|
+
action('confirm').hidden = !view.confirmRepair;
|
|
69
|
+
find('verify').querySelector('a').hidden = !view.checkPort;
|
|
70
|
+
find('verify').hidden = (!view.confirmRepair && !view.checkPort) || !!warning || warnGuide;
|
|
71
|
+
for (const button of panel.querySelectorAll('button')) button.disabled = posting;
|
|
72
|
+
}
|
|
73
|
+
const off = watchExtensionUpdate(render);
|
|
74
|
+
signal.addEventListener('abort', off, { once: true });
|
|
75
|
+
async function post(path, body) {
|
|
76
|
+
let focusWarning = false;
|
|
77
|
+
posting = true; feedback(''); render(update);
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetch(`/api/browser/extension/${path}`, { method: 'POST', signal,
|
|
80
|
+
headers: { 'Content-Type': 'application/json', 'X-SynaBun-UI': '1' }, body: JSON.stringify(body) });
|
|
81
|
+
const value = await response.json();
|
|
82
|
+
if (signal.aborted) return;
|
|
83
|
+
if (value.update) acceptExtensionUpdate(value.update);
|
|
84
|
+
if (value.code === 'RELOAD_BUSY') { warning = 'reload'; focusWarning = true; }
|
|
85
|
+
else if (!response.ok && !value.update) feedback(t('actionFailed'));
|
|
86
|
+
await refreshExtensionUpdate();
|
|
87
|
+
} catch { if (!signal.aborted) feedback(t('actionFailed')); }
|
|
88
|
+
finally {
|
|
89
|
+
posting = false;
|
|
90
|
+
if (!signal.aborted) { render(update); if (focusWarning && warning) action('wait').focus(); }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function warn(kind) { warning = kind; render(update); action('wait').focus(); }
|
|
94
|
+
panel.addEventListener('click', async event => {
|
|
95
|
+
const name = event.target.closest('[data-update-action]')?.dataset.updateAction;
|
|
96
|
+
if (!name || !view || posting || event.isTrusted === false) return;
|
|
97
|
+
if (name === 'chrome' || name === 'edge') {
|
|
98
|
+
const url = name === 'edge' ? 'edge://extensions' : 'chrome://extensions';
|
|
99
|
+
try { await navigator.clipboard.writeText(url); feedback(t('copied', { url })); }
|
|
100
|
+
catch { feedback(t('copyManually', { url })); }
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (name === 'wait') { const opener = warning; warning = null; render(update); action(opener)?.focus(); return; }
|
|
104
|
+
if (name === 'continue' && warning) {
|
|
105
|
+
const choice = warning; warning = null;
|
|
106
|
+
if (choice === 'guide') { allowGuide = true; render(update); action('chrome').focus(); }
|
|
107
|
+
else await post('reload', { targetVersion: update.targetVersion, allowBusy: true });
|
|
108
|
+
} else if (name === 'guide') warn('guide');
|
|
109
|
+
else if (name === 'reload' && view.updateNow) {
|
|
110
|
+
if (view.busy) warn('reload'); else await post('reload', { targetVersion: update.targetVersion, allowBusy: false });
|
|
111
|
+
} else if (name === 'retry' && (view.retry || view.download)) await post('update', {});
|
|
112
|
+
else if (name === 'confirm' && view.confirmRepair) await post('reload/confirm', { reloaded: true });
|
|
113
|
+
}, { signal });
|
|
114
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// What a Stop that could not end a command in the background says, in the OpenCode side panel and the Assistant
|
|
2
|
+
// panel alike. DOM-free, no imports (node --test loads it). SHELL_STOP_COPY is the English and must equal
|
|
3
|
+
// `shellStop.*` in i18n/*.json (tests/opencode-stop-anyway.test.mjs checks it).
|
|
4
|
+
//
|
|
5
|
+
// The server's answer to a failed Stop (server.js message:abort, lib/assistant-runtime.js stopTurn) carries
|
|
6
|
+
// `shells: [{ id, command, reason }]`, `failures` (how many Stops of this turn failed) and `canForce` (from the second
|
|
7
|
+
// one on): "Stop anyway" is offered then. A Stop anyway that ended the turn while a command may still run answers
|
|
8
|
+
// `abandoned: [{ id, command }]`.
|
|
9
|
+
|
|
10
|
+
export const SHELL_STOP_COPY = Object.freeze({
|
|
11
|
+
failed: 'Stop could not end {commands} ({reason}). It is still running, so this turn goes on. Press Stop again.',
|
|
12
|
+
failedAgain: 'Stop could not end {commands} again ({reason}). It is still running. Press Stop again, or Stop anyway to end this turn here.',
|
|
13
|
+
anyway: 'Stop anyway',
|
|
14
|
+
abandoned: 'Turn stopped. {commands} may still be running on this machine: SynaBun keeps trying to end it in the background.',
|
|
15
|
+
unknownReason: 'no reason given',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const fill = (text, vars = {}) => String(text).replace(/\{(\w+)\}/g, (_, key) => (vars[key] != null ? String(vars[key]) : `{${key}}`));
|
|
19
|
+
|
|
20
|
+
/** The string `key` in the active locale through `translate(key, vars)` (a missing key comes back as itself), else the English. */
|
|
21
|
+
export function shellStopText(key, vars = {}, translate = null) {
|
|
22
|
+
const full = `shellStop.${key}`;
|
|
23
|
+
let said = null;
|
|
24
|
+
try { said = typeof translate === 'function' ? translate(full, vars) : null; } catch { said = null; }
|
|
25
|
+
if (typeof said === 'string' && said && said !== full) return said;
|
|
26
|
+
return fill(SHELL_STOP_COPY[key] ?? '', vars);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const named = (shells) => (Array.isArray(shells) ? shells : [])
|
|
30
|
+
.map((shell) => String(shell?.command || shell?.id || '').trim())
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.map((name) => `“${name.length > 80 ? `${name.slice(0, 79)}…` : name}”`)
|
|
33
|
+
.join(', ');
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A failed Stop's answer → `{ message, canForce }`, or null when the answer is no such failure. An answer of a server
|
|
37
|
+
* from before this (no `shells`) keeps its own sentence.
|
|
38
|
+
*/
|
|
39
|
+
export function describeStopFailure(result, translate = null) {
|
|
40
|
+
if (!result || (result.code !== 'SHELL_STOP_FAILED' && result.code !== 'STOP_FAILED')) return null;
|
|
41
|
+
const shells = Array.isArray(result.shells) ? result.shells : [];
|
|
42
|
+
const canForce = result.canForce === true;
|
|
43
|
+
if (!shells.length) {
|
|
44
|
+
const fallback = String(result.error || result.message || '').trim();
|
|
45
|
+
return { message: fallback || shellStopText('failed', { commands: '—', reason: shellStopText('unknownReason', {}, translate) }, translate), canForce };
|
|
46
|
+
}
|
|
47
|
+
const reasons = [...new Set(shells.map((shell) => String(shell?.reason || '').trim()).filter(Boolean))].join('; ');
|
|
48
|
+
const vars = { commands: named(shells), reason: reasons || shellStopText('unknownReason', {}, translate) };
|
|
49
|
+
return { message: shellStopText(canForce ? 'failedAgain' : 'failed', vars, translate), canForce };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Words in front of the program that are not it: a variable set for the command, and the runners that start another.
|
|
53
|
+
const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
54
|
+
const RUNNERS = new Set(['sudo', 'env', 'nohup', 'time', 'exec', 'command', 'nice', 'caffeinate', 'stdbuf', 'timeout']);
|
|
55
|
+
// A shell's own words (a loop, a test): no program is named by them, so the command is "a command".
|
|
56
|
+
const SHELL_WORDS = new Set(['for', 'while', 'until', 'if', 'case', 'select', 'function', 'do', 'then']);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The program a command line starts, by its name only (`npm`, `curl`): what a place outside the machine (a phone, a
|
|
60
|
+
* run's result, a memory) may be told. Nothing after it (arguments, a URL, a header, a token) and nothing before it
|
|
61
|
+
* (`TOKEN=… cmd`, `sudo`) is kept, nor a folder. A name that is not plainly a program's is `''`.
|
|
62
|
+
*/
|
|
63
|
+
export function commandProgram(command) {
|
|
64
|
+
const words = String(command || '').trim().split(/\s+/).filter(Boolean);
|
|
65
|
+
let index = 0;
|
|
66
|
+
while (index < words.length && (ASSIGNMENT.test(words[index]) || RUNNERS.has(words[index]) || /^-/.test(words[index]) || (index > 0 && /^\d+[smhd]?$/.test(words[index])))) index += 1;
|
|
67
|
+
const word = (words[index] || '').replace(/^["'(]+|["');&|]+$/g, '');
|
|
68
|
+
const name = word.split(/[\\/]/).pop() || '';
|
|
69
|
+
if (SHELL_WORDS.has(name)) return '';
|
|
70
|
+
return /^[A-Za-z0-9][A-Za-z0-9._+-]{0,39}$/.test(name) ? name : '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The program names of `shells` (`{ command }`), each once, in order; a command whose name is unclear is "a command". */
|
|
74
|
+
export function abandonedPrograms(shells) {
|
|
75
|
+
const names = (Array.isArray(shells) ? shells : []).map((shell) => commandProgram(shell?.command) || 'command');
|
|
76
|
+
return [...new Set(names)];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A Stop anyway's answer → the sentence about the commands that may still run, or null when none was left. */
|
|
80
|
+
export function describeAbandoned(abandoned, translate = null) {
|
|
81
|
+
const commands = named(abandoned);
|
|
82
|
+
return commands ? shellStopText('abandoned', { commands }, translate) : null;
|
|
83
|
+
}
|
|
@@ -4063,6 +4063,9 @@
|
|
|
4063
4063
|
opacity: 0;
|
|
4064
4064
|
transition: opacity 0.15s, color 0.15s;
|
|
4065
4065
|
}
|
|
4066
|
+
.notif-toast[data-persistent] { --notif-accent: var(--t-secondary); cursor: default; }
|
|
4067
|
+
.notif-toast[data-persistent] .cli-detect-btn { margin-top: 8px; }
|
|
4068
|
+
.notif-toast[data-persistent] .notif-toast-close { opacity: 1; }
|
|
4066
4069
|
.notif-toast:hover .notif-toast-close {
|
|
4067
4070
|
opacity: 1;
|
|
4068
4071
|
}
|
|
@@ -16134,6 +16137,7 @@
|
|
|
16134
16137
|
top to bottom, every row wraps, and nothing is positioned or given a height, so no paragraph can lie over another
|
|
16135
16138
|
at any width or in any language. Colours are the panel's --stg-* tokens; controls keep Settings' 22 px geometry. */
|
|
16136
16139
|
.settings-panel .stg-field.bc-extension { display: block; min-width: 0; }
|
|
16140
|
+
.settings-panel #bc-update-progress { width: 100%; accent-color: var(--stg-accent-fill); }
|
|
16137
16141
|
.settings-panel .bc-extension .bc-ext-label {
|
|
16138
16142
|
display: block; margin: 0; min-width: 0;
|
|
16139
16143
|
font-size: 13px; font-weight: 400; line-height: 1.4; color: var(--stg-text); overflow-wrap: anywhere;
|
|
@@ -22,6 +22,10 @@ const CROUCH = [26, 0.45]; // the take-off squash, rubbery
|
|
|
22
22
|
const SCALE = [14, 0.72];
|
|
23
23
|
const ARRIVED = { px: 4, speed: 140 }; // close and slow enough for the beat to go on (the spring finishes on its own)
|
|
24
24
|
const KEEP_OUT_MARGIN = 6; // px of clear board round what the mascot draws
|
|
25
|
+
// The face width (CSS px) the beats are choreographed for: a place's `scale` is relative to it, whatever size the
|
|
26
|
+
// host draws the face at (the empty state's hero is 280 × 140 since v2.3.0; the tour's places, its ink and its
|
|
27
|
+
// keep-outs were laid out round a 120 × 60 face, which a 320 px board has room for). Home is the face's own size.
|
|
28
|
+
const TOUR_FACE_W = 120;
|
|
25
29
|
|
|
26
30
|
export function createActor(target, { reduced = () => false, onMove = null } = {}) {
|
|
27
31
|
const rig = target.rig;
|
|
@@ -80,6 +84,13 @@ export function createActor(target, { reduced = () => false, onMove = null } = {
|
|
|
80
84
|
return rect;
|
|
81
85
|
}
|
|
82
86
|
|
|
87
|
+
/** The transform scale for a place: home (no point) is the face's own size, any other place the tour's face size times `scale`. */
|
|
88
|
+
function kFor(point, scale = 1) {
|
|
89
|
+
if (!point) return 1;
|
|
90
|
+
const w = base?.w;
|
|
91
|
+
return w > 0 ? scale * (TOUR_FACE_W / w) : scale;
|
|
92
|
+
}
|
|
93
|
+
|
|
83
94
|
const tellMove = () => { if (onMove && base) try { onMove(boundsAt(s.x, s.y + s.arc, s.k)); } catch { /* the host's */ } };
|
|
84
95
|
|
|
85
96
|
function write() {
|
|
@@ -146,7 +157,7 @@ export function createActor(target, { reduced = () => false, onMove = null } = {
|
|
|
146
157
|
}
|
|
147
158
|
|
|
148
159
|
/**
|
|
149
|
-
* Fly to `point` (client px; null = home) at `scale
|
|
160
|
+
* Fly to `point` (client px; null = home, at the face's own size) at `scale` (of TOUR_FACE_W). Resolves once it has
|
|
150
161
|
* arrived closely enough for the next op (the landing finishes on its own),
|
|
151
162
|
* at once under reduced motion or when there is no character on screen.
|
|
152
163
|
*/
|
|
@@ -154,7 +165,7 @@ export function createActor(target, { reduced = () => false, onMove = null } = {
|
|
|
154
165
|
place = { point: point ? { ...point } : null, scale };
|
|
155
166
|
if (!present()) return Promise.resolve();
|
|
156
167
|
const c = readBase() ? { x: base.cx, y: base.cy } : layoutCentre();
|
|
157
|
-
const to = { x: point ? point.x - c.x : 0, y: point ? point.y - c.y : 0, k: scale };
|
|
168
|
+
const to = { x: point ? point.x - c.x : 0, y: point ? point.y - c.y : 0, k: kFor(point, scale) };
|
|
158
169
|
const dist = Math.hypot(to.x - s.x, to.y - s.y);
|
|
159
170
|
Object.assign(goal, to);
|
|
160
171
|
if (reduced()) {
|
|
@@ -196,7 +207,7 @@ export function createActor(target, { reduced = () => false, onMove = null } = {
|
|
|
196
207
|
if (!svg) return null;
|
|
197
208
|
if (!base) readBase();
|
|
198
209
|
if (!base) return null;
|
|
199
|
-
return boundsAt(point ? point.x - base.cx : 0, point ? point.y - base.cy : 0, scale, margin);
|
|
210
|
+
return boundsAt(point ? point.x - base.cx : 0, point ? point.y - base.cy : 0, kFor(point, scale), margin);
|
|
200
211
|
}
|
|
201
212
|
|
|
202
213
|
/** The face's client rect where it will land (its goal), for ink placed beside it. */
|
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import { KEYS } from './constants.js';
|
|
2
2
|
import { trayColumnOf } from './ui-tray-columns.js';
|
|
3
3
|
|
|
4
|
+
// What a tray pill tells this toggle it must leave open: a tab whose close would destroy what the user cannot get
|
|
5
|
+
// back (a Claude Code temporary chat, an unsent draft). The panels decide; this module only asks. A pill says it
|
|
6
|
+
// twice: `pill.keepFromAutoClose()` is the live answer asked right before a close, and the attribute below is the
|
|
7
|
+
// signal the observer watches, so a reason that appears or goes away while the pill sits in Done is checked again
|
|
8
|
+
// at once. The user's own X asks neither. (Here, not in a module of their own: this one is loaded before the page
|
|
9
|
+
// is shown and the panels are not, tests/boot-critical-path.test.mjs.)
|
|
10
|
+
export const AUTO_CLOSE_KEEP_ATTR = 'data-auto-close-keep';
|
|
11
|
+
|
|
12
|
+
/** Whether a composer holds something unsent: text that is not only blanks, or any attachment list with an entry. */
|
|
13
|
+
export function composerHoldsDraft(text, ...attachments) {
|
|
14
|
+
return !!String(text ?? '').trim() || attachments.some(list => (list?.length || 0) > 0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Writes a pill's reason ('' or none: nothing to keep), only when it changed (the toggle observes it). */
|
|
18
|
+
export function markAutoCloseKeep(pill, reason) {
|
|
19
|
+
if (!pill?.dataset) return;
|
|
20
|
+
const value = reason ? String(reason) : '';
|
|
21
|
+
if ((pill.dataset.autoCloseKeep || '') === value) return;
|
|
22
|
+
if (value) pill.dataset.autoCloseKeep = value;
|
|
23
|
+
else delete pill.dataset.autoCloseKeep;
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
const agents = ['cp', 'cxp', 'ocpv2', 'agy', 'mtc'].map(prefix => prefix + '-session-pill');
|
|
5
27
|
const excluded = ['asp-session-pill', 'sp-session-pill', 'sidepanel-tray-placeholder', 'ocpv2-session-pill-child'];
|
|
6
28
|
const unfinishedOrFailed = /^(?:running|waiting|error|errored|failed)$/i;
|
|
29
|
+
// The provider a pill's automation run belongs to, by the pill's own class (a run the server no longer
|
|
30
|
+
// keeps names no provider: ui-native-loop-router.js autoCloseNativeLoopTab).
|
|
31
|
+
const runProviders = { 'cp-session-pill': 'claude-code', 'cxp-session-pill': 'codex', 'ocpv2-session-pill': 'opencode', 'agy-session-pill': 'antigravity' };
|
|
32
|
+
const runProviderOf = pill => runProviders[Object.keys(runProviders).find(name => pill.classList.contains(name))] || null;
|
|
7
33
|
|
|
8
34
|
// Only direct provider pills can close. A collapsed Done column is still eligible.
|
|
9
35
|
export function canAutoClose(pill, tray) {
|
|
@@ -12,8 +38,9 @@ export function canAutoClose(pill, tray) {
|
|
|
12
38
|
if (!agents.some(name => classes.contains(name)) || excluded.some(name => classes.contains(name))) return false;
|
|
13
39
|
if (pill.querySelector('.cli-status-badge') || unfinishedOrFailed.test(pill.dataset.status) ||
|
|
14
40
|
/\S+-pill-(?:error|errored|failed)(?:\s|$)/.test(pill.className)) return false;
|
|
15
|
-
// The producer may have started another turn or queued a prompt before the next frame.
|
|
16
|
-
|
|
41
|
+
// The producer may have started another turn or queued a prompt before the next frame. A pill whose close
|
|
42
|
+
// would destroy what the user cannot get back (a temporary chat, an unsent draft) says so (AUTO_CLOSE_KEEP_ATTR).
|
|
43
|
+
return trayColumnOf(pill) === 'done' && !pill.hasQueuedWorkerPrompts?.() && !pill.keepFromAutoClose?.();
|
|
17
44
|
}
|
|
18
45
|
|
|
19
46
|
export function initTrayAutoClose(tray, button, storage, t, closeAutomationTab) {
|
|
@@ -49,11 +76,14 @@ export function initTrayAutoClose(tray, button, storage, t, closeAutomationTab)
|
|
|
49
76
|
if (x) {
|
|
50
77
|
requested.add(pill); // Some close handlers remove the pill asynchronously.
|
|
51
78
|
const runId = pill.getAutomationRunId?.();
|
|
52
|
-
|
|
79
|
+
// A pill whose X destroys something (OpenCode's deletes the session) has a close of its own for this.
|
|
80
|
+
if (!runId && !pill.detachForAutoClose) { x.click(); return; }
|
|
53
81
|
// An idle automation also appears in Done. Its X is a deliberate stop.
|
|
54
82
|
// Only the conditional completion path may dismiss it automatically.
|
|
55
|
-
try {
|
|
56
|
-
|
|
83
|
+
try {
|
|
84
|
+
if (runId) await closeAutomationTab?.(runId, runProviderOf(pill));
|
|
85
|
+
else await pill.detachForAutoClose();
|
|
86
|
+
} finally { requested.delete(pill); }
|
|
57
87
|
}
|
|
58
88
|
}
|
|
59
89
|
|
|
@@ -102,7 +132,7 @@ export function initTrayAutoClose(tray, button, storage, t, closeAutomationTab)
|
|
|
102
132
|
button.classList.toggle('active', enabled);
|
|
103
133
|
if (enabled) {
|
|
104
134
|
observer.observe(tray, { subtree: true, childList: true, attributes: true, attributeOldValue: true,
|
|
105
|
-
attributeFilter: ['data-tray-col', 'data-status', 'class', 'style', 'hidden'] });
|
|
135
|
+
attributeFilter: ['data-tray-col', 'data-status', 'class', 'style', 'hidden', AUTO_CLOSE_KEEP_ATTR] });
|
|
106
136
|
for (const pill of [...tray.children]) reconcile(pill, immediate);
|
|
107
137
|
} else {
|
|
108
138
|
observer.disconnect();
|