dsh-builtin-browser 1.0.1 → 1.0.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 +55 -0
- package/README.md +1 -1
- package/assets/browser-panel-locales.mjs +37 -5
- package/assets/browser-policy.d.mts +29 -0
- package/assets/browser-policy.mjs +40 -0
- package/desktop-bridge/desktop-discovery.d.mts +1 -1
- package/desktop-bridge/desktop-discovery.mjs +59 -9
- package/desktop-bridge/desktop-identity.json +12 -0
- package/desktop-bridge/install.mjs +14 -7
- package/desktop-bridge/plugin-browser-bridge.js +19 -7
- package/docs/acceptance-2026-11-27.md +67 -0
- package/docs/architecture.md +1 -1
- package/docs/development.md +33 -4
- package/docs/dsh-0.2.3-host-patch-task.md +34 -0
- package/docs/hardcoding-audit.md +28 -8
- package/docs/known-issues.md +26 -0
- package/docs/limitations.md +6 -2
- package/docs/tool-reference.md +1 -1
- package/docs/v1.1.0-bu-data-batching-task.md +66 -0
- package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
- package/dsh-host-patch/README.md +4 -0
- package/dsh-host-patch/apply.mjs +61 -13
- package/dsh-host-patch/rc3-revision9.json.gz +0 -0
- package/dsh-host-patch/rc5-revision9.json.gz +0 -0
- package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
- package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
- package/dsh-host-patch/tauri-revision1.json +39 -0
- package/dsh-host-patch/tauri.json +43 -0
- package/dsh-host-patch/v023-alpha2.json +153 -0
- package/lib/browser/anti-bot.js +215 -0
- package/lib/browser/deep-dom.js +39 -0
- package/lib/browser/runtime.js +15 -0
- package/lib/browser/takeover-target.js +13 -6
- package/lib/browser/types.js +30 -1
- package/lib/browser-electron/authenticated-route.js +16 -2
- package/lib/browser-electron/automatic-maintenance.js +16 -10
- package/lib/browser-electron/bridge-connection.js +3 -8
- package/lib/browser-electron/bridge-install.js +2 -1
- package/lib/browser-electron/bridge-status.js +55 -26
- package/lib/browser-electron/desktop-bridge-host.js +7 -6
- package/lib/browser-electron/desktop-identity.js +28 -5
- package/lib/browser-electron/desktop-shell.js +64 -0
- package/lib/browser-electron/electron-provision.js +105 -18
- package/lib/browser-electron/entry.js +129 -44
- package/lib/browser-electron/extension-browser.js +4 -4
- package/lib/browser-electron/foreground-watch.js +134 -0
- package/lib/browser-electron/guest-cookie-jar.js +13 -13
- package/lib/browser-electron/guest-route.js +181 -32
- package/lib/browser-electron/guest-runtime.js +61 -10
- package/lib/browser-electron/guest-storage.js +2 -2
- package/lib/browser-electron/history-store.js +1 -5
- package/lib/browser-electron/host-main.js +8 -4
- package/lib/browser-electron/host-patch-maintenance.js +14 -8
- package/lib/browser-electron/maintenance-route.js +2 -1
- package/lib/browser-electron/missing-system-browser.js +5 -9
- package/lib/browser-electron/preferred-browser.js +7 -3
- package/lib/browser-electron/preview-route.js +9 -13
- package/lib/browser-electron/process-ownership.js +1 -1
- package/lib/browser-electron/profile-command.js +2 -1
- package/lib/browser-electron/profile-extension.js +5 -0
- package/lib/browser-electron/profile-lease.js +152 -47
- package/lib/browser-electron/provider-core.js +527 -0
- package/lib/browser-electron/provider-interaction.js +963 -0
- package/lib/browser-electron/provider-media.js +518 -0
- package/lib/browser-electron/provider-navigation.js +301 -0
- package/lib/browser-electron/provider-observation.js +623 -0
- package/lib/browser-electron/provider-tabs.js +372 -0
- package/lib/browser-electron/provider.js +150 -3301
- package/lib/browser-electron/reference-route.js +9 -18
- package/lib/browser-electron/remote-host.js +79 -34
- package/lib/browser-electron/runtime-status.js +56 -6
- package/lib/browser-electron/settings-store.js +3 -6
- package/lib/browser-electron/sidebar-only-host.js +1 -1
- package/lib/browser-electron/system-browser.js +539 -172
- package/lib/browser-electron/tauri-host.js +208 -0
- package/lib/browser-electron/virtual-cursor.js +23 -13
- package/lib/browser-reference/service.js +22 -4
- package/lib/browser-reference/web-sources.js +1 -1
- package/lib/client.js +43409 -0
- package/lib/compat/host-features.js +75 -0
- package/lib/reference-source.js +1 -1
- package/lib/reference-text.js +23 -1
- package/lib/takeover-protocol.js +1 -1
- package/lib/tool-browser/block-recovery.js +69 -0
- package/lib/tool-browser/code-tool.js +170 -19
- package/lib/tool-browser/code-worker.js +115 -20
- package/lib/tool-browser/errors.js +34 -0
- package/lib/tool-browser/index.js +66 -3593
- package/lib/tool-browser/page-probe.js +227 -28
- package/lib/tool-browser/panel-page.js +2 -1
- package/lib/tool-browser/probe-client.js +157 -0
- package/lib/tool-browser/screenshot-annotations.js +108 -0
- package/lib/tool-browser/state.js +337 -0
- package/lib/tool-browser/takeover.js +1 -1
- package/lib/tool-browser/tools-debug.js +862 -0
- package/lib/tool-browser/tools-interaction.js +993 -0
- package/lib/tool-browser/tools-navigation.js +807 -0
- package/lib/tool-browser/tools-observation.js +461 -0
- package/lib/tool-browser/tools-reference.js +293 -0
- package/lib/web-guest.js +1 -0
- package/package.json +16 -36
- package/scripts/build-client.mjs +305 -0
- package/scripts/build.mjs +15 -12
- package/scripts/fix-exports.mjs +6 -16
- package/scripts/install-electron.mjs +55 -5
- package/scripts/pack.mjs +99 -0
- package/scripts/publish-manifest.mjs +56 -0
- package/scripts/verify-exports.mjs +26 -15
- package/skills/dsh-builtin-browser/SKILL.md +27 -2
- package/skills/dsh-builtin-browser/references/batch.md +15 -0
- package/src/browser/anti-bot.ts +251 -0
- package/src/browser/deep-dom.ts +40 -0
- package/src/browser/runtime.ts +18 -0
- package/src/browser/takeover-target.ts +16 -7
- package/src/browser/types.ts +56 -3
- package/src/browser-electron/authenticated-route.ts +29 -4
- package/src/browser-electron/automatic-maintenance.ts +23 -13
- package/src/browser-electron/bridge-connection.ts +11 -10
- package/src/browser-electron/bridge-install.ts +2 -1
- package/src/browser-electron/bridge-status.ts +61 -22
- package/src/browser-electron/desktop-bridge-host.ts +9 -7
- package/src/browser-electron/desktop-identity.ts +38 -5
- package/src/browser-electron/desktop-shell.ts +100 -0
- package/src/browser-electron/electron-provision.ts +104 -18
- package/src/browser-electron/entry.ts +1378 -1299
- package/src/browser-electron/extension-browser.ts +11 -4
- package/src/browser-electron/foreground-watch.ts +142 -0
- package/src/browser-electron/guest-cookie-jar.ts +3 -2
- package/src/browser-electron/guest-route.ts +180 -32
- package/src/browser-electron/guest-runtime.ts +61 -10
- package/src/browser-electron/guest-storage.ts +5 -2
- package/src/browser-electron/history-store.ts +3 -6
- package/src/browser-electron/host-main.ts +8 -4
- package/src/browser-electron/host-patch-maintenance.ts +18 -9
- package/src/browser-electron/maintenance-route.ts +2 -1
- package/src/browser-electron/missing-system-browser.ts +11 -10
- package/src/browser-electron/preferred-browser.ts +13 -3
- package/src/browser-electron/preview-route.ts +9 -12
- package/src/browser-electron/process-ownership.ts +9 -3
- package/src/browser-electron/profile-command.ts +2 -1
- package/src/browser-electron/profile-extension.ts +5 -0
- package/src/browser-electron/profile-lease.ts +131 -35
- package/src/browser-electron/provider-core.ts +1107 -0
- package/src/browser-electron/provider-interaction.ts +1034 -0
- package/src/browser-electron/provider-media.ts +589 -0
- package/src/browser-electron/provider-navigation.ts +323 -0
- package/src/browser-electron/provider-observation.ts +664 -0
- package/src/browser-electron/provider-tabs.ts +372 -0
- package/src/browser-electron/provider.ts +158 -4063
- package/src/browser-electron/reference-route.ts +598 -608
- package/src/browser-electron/remote-host.ts +118 -42
- package/src/browser-electron/runtime-status.ts +80 -13
- package/src/browser-electron/settings-store.ts +10 -6
- package/src/browser-electron/sidebar-only-host.ts +4 -2
- package/src/browser-electron/system-browser.ts +537 -184
- package/src/browser-electron/tauri-host.ts +194 -0
- package/src/browser-electron/virtual-cursor.ts +24 -14
- package/src/browser-reference/service.ts +38 -7
- package/src/browser-reference/web-sources.ts +4 -1
- package/src/client/apply-guard.ts +22 -0
- package/src/client/browser/BrowserController.ts +3 -3
- package/src/client/browser/IframeImpl.ts +182 -176
- package/src/client/browser/frame-history.ts +125 -0
- package/src/client/browser/frame-state.ts +27 -0
- package/src/client/browser/web-reference-source.ts +5 -1
- package/src/client/definition.tsx +36 -30
- package/src/client/electron/ElectronWebViewImpl.ts +20 -13
- package/src/client/electron/ElectronWebviewPresentation.ts +4 -2
- package/src/client/electron/NativeChildPresentation.ts +11 -3
- package/src/client/electron/NativeViewPage.ts +19 -5
- package/src/client/index.ts +333 -293
- package/src/client/locales.ts +9 -6
- package/src/client/reference/client/plugin.ts +21 -2
- package/src/client/reference/client/production/ReferenceCapsules.tsx +3 -3
- package/src/client/reference/client/production/assembly.ts +4 -28
- package/src/client/reference/client/production/availability.ts +0 -2
- package/src/client/reference/client/production/composer-attachments.ts +44 -0
- package/src/client/reference/client/production/draft-adapter.ts +4 -0
- package/src/client/reference/client/production/http-transport.ts +0 -5
- package/src/client/reference/client/production/production-submission.ts +50 -290
- package/src/client/reference/client/production/protocol.ts +7 -4
- package/src/client/reference/client/production/runtime.ts +41 -86
- package/src/client/reference/client/production/source-marker.ts +49 -13
- package/src/client/reference/client/production/user-text-rule.ts +10 -1
- package/src/client/reference/client/reveal.ts +3 -1
- package/src/client/reference/client/session-schedule.ts +36 -0
- package/src/client/settings/index.ts +8 -0
- package/src/client/settings/mount-guard.ts +31 -0
- package/src/client/settings/panel.ts +163 -52
- package/src/client/startpage/controller.ts +3 -6
- package/src/client/view/BrowserBody.tsx +2 -1
- package/src/client/view/IframePresentation.ts +37 -16
- package/src/client/view/StartPage.tsx +2 -1
- package/src/compat/host-features.ts +92 -0
- package/src/reference-source.ts +1 -1
- package/src/reference-text.ts +23 -1
- package/src/takeover-protocol.ts +11 -2
- package/src/tool-browser/block-recovery.ts +85 -0
- package/src/tool-browser/code-tool.ts +173 -19
- package/src/tool-browser/code-worker.ts +101 -15
- package/src/tool-browser/errors.ts +40 -0
- package/src/tool-browser/index.ts +66 -3534
- package/src/tool-browser/page-probe.ts +229 -28
- package/src/tool-browser/panel-page.ts +3 -1
- package/src/tool-browser/probe-client.ts +183 -0
- package/src/tool-browser/screenshot-annotations.ts +131 -0
- package/src/tool-browser/state.ts +375 -0
- package/src/tool-browser/takeover.ts +3 -2
- package/src/tool-browser/tools-debug.ts +806 -0
- package/src/tool-browser/tools-interaction.ts +956 -0
- package/src/tool-browser/tools-navigation.ts +786 -0
- package/src/tool-browser/tools-observation.ts +474 -0
- package/src/tool-browser/tools-reference.ts +294 -0
- package/src/web-guest.ts +35 -34
- package/dist/client.cjs +0 -43167
- package/dist/client.d.cts +0 -516
- package/dist/client.d.mts +0 -516
- package/dist/index.cjs +0 -92
- package/dist/index.d.mts +0 -2960
- package/dist/index.mjs +0 -24
- package/lib/browser-reference/submission-receipts.js +0 -139
- package/src/browser-reference/submission-receipts.ts +0 -122
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { zh, en } from '../../../assets/browser-panel-locales.mjs'
|
|
2
|
-
import { REFERENCE_REVEAL_ROUTE, REFERENCE_INSERT_ROUTE, REFERENCE_IMPORT_ROUTE, REFERENCE_DELIVERY_REMOVE_ROUTE, PREVIEW_ROUTE, PREVIEW_SESSIONS_ROUTE, BRIDGE_STATUS_ROUTE, RUNTIME_STATUS_ROUTE, RUNTIME_PROVISION_ROUTE } from '../../../assets/browser-policy.mjs'
|
|
2
|
+
import { REFERENCE_REVEAL_ROUTE, REFERENCE_INSERT_ROUTE, REFERENCE_IMPORT_ROUTE, REFERENCE_DELIVERY_REMOVE_ROUTE, REFERENCE_LIST_ROUTE, REFERENCE_EXPORT_ROUTE, OPEN_REQUEST_ROUTE, HOST_PATCH_ROUTE, AUTOMATIC_MAINTENANCE_ROUTE, PREVIEW_ROUTE, PREVIEW_SESSIONS_ROUTE, BRIDGE_STATUS_ROUTE, RUNTIME_STATUS_ROUTE, RUNTIME_PROVISION_ROUTE } from '../../../assets/browser-policy.mjs'
|
|
3
3
|
import { SETTINGS_ROUTE, EXTENSION_INSTALL_ROUTE } from '../../../assets/browser-policy.mjs'
|
|
4
|
+
import { nativeViews } from '../../compat/host-features.ts'
|
|
4
5
|
/**
|
|
5
6
|
* 设置面板(客户端半):从旧插件的 ModuleLoader bundle 机械移植而来,内部实现未改一行。
|
|
6
7
|
*
|
|
@@ -378,7 +379,11 @@ const react = require("react")
|
|
|
378
379
|
// the label next to them is always a locale string.
|
|
379
380
|
badge: { display: "inline-block", padding: "1px 8px", marginRight: "8px", borderRadius: "10px", fontSize: "11px", lineHeight: 1.6, border: "1px solid transparent" },
|
|
380
381
|
badgeOk: { color: "#2f9e44", borderColor: "rgba(47,158,68,.5)", background: "rgba(47,158,68,.12)" },
|
|
381
|
-
|
|
382
|
+
// Amber is "recoverable, act if you want"; red is reserved for a real failure. A blocked
|
|
383
|
+
// readiness whose extension is simply not connected used to be red, which read as "your
|
|
384
|
+
// browser was found but it is broken".
|
|
385
|
+
badgeWarn: { color: "#b26a00", borderColor: "rgba(178,106,0,.5)", background: "rgba(178,106,0,.12)" },
|
|
386
|
+
badgeError: { color: "#e5534b", borderColor: "rgba(229,83,75,.5)", background: "rgba(229,83,75,.12)" },
|
|
382
387
|
badgeUnknown: { color: "#a0a0a8", borderColor: "rgba(160,160,168,.5)", background: "rgba(160,160,168,.12)" },
|
|
383
388
|
kv: { display: "grid", gridTemplateColumns: "auto 1fr", gap: "3px 12px", margin: "8px 0 0", fontSize: "12px" },
|
|
384
389
|
kvKey: { opacity: 0.68 },
|
|
@@ -568,12 +573,12 @@ const react = require("react")
|
|
|
568
573
|
}, [])
|
|
569
574
|
useEffect(() => {
|
|
570
575
|
alive.current = true
|
|
571
|
-
void fetch(
|
|
576
|
+
void fetch(HOST_PATCH_ROUTE, { headers: { accept: "application/json" } })
|
|
572
577
|
.then(async response => {
|
|
573
578
|
if (response.status === 404) return
|
|
574
579
|
const data = await response.json()
|
|
575
580
|
if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`)
|
|
576
|
-
if (alive.current && data.hostPatch?.surface === "web") setState(data.hostPatch)
|
|
581
|
+
if (alive.current && (data.hostPatch?.surface === "web" || data.hostPatch?.surface === "tauri")) setState(data.hostPatch)
|
|
577
582
|
}).catch(failure => { if (alive.current) setError(String(failure)) })
|
|
578
583
|
return () => { alive.current = false }
|
|
579
584
|
}, [])
|
|
@@ -582,33 +587,43 @@ const react = require("react")
|
|
|
582
587
|
pending.current = true
|
|
583
588
|
setBusy(true); setError(""); setNotice(""); publishHostPatchNotice("")
|
|
584
589
|
try {
|
|
585
|
-
const response = await fetch(
|
|
590
|
+
const response = await fetch(HOST_PATCH_ROUTE, {
|
|
586
591
|
method: "POST", headers: { accept: "application/json", "content-type": "application/json" },
|
|
587
592
|
body: JSON.stringify({ action }),
|
|
588
593
|
})
|
|
589
594
|
const data = await response.json()
|
|
590
595
|
if (alive.current && data.hostPatch) setState(data.hostPatch)
|
|
591
596
|
if (!response.ok || data.ok !== true) throw new Error(data.error || data.hostPatch?.reason || `HTTP ${response.status}`)
|
|
592
|
-
const noticeKey = data.hostPatch.restartRequired ? "hostPatch.restart" : "hostPatch.reload"
|
|
597
|
+
const noticeKey = data.hostPatch.surface === "tauri" ? "hostPatch.restartTauri" : data.hostPatch.restartRequired ? "hostPatch.restart" : "hostPatch.reload"
|
|
593
598
|
publishHostPatchNotice(noticeKey)
|
|
594
599
|
if (alive.current) setNotice(noticeKey)
|
|
595
600
|
} catch (failure) { if (alive.current) setError(String(failure)) }
|
|
596
601
|
finally { pending.current = false; if (alive.current) setBusy(false) }
|
|
597
602
|
}
|
|
598
603
|
if (state === null && error === "") return null
|
|
604
|
+
// The host says whether this line needs a patch at all (its spec carries `native`). A host that
|
|
605
|
+
// already supports the feature keeps the section out; older lines still get one action.
|
|
606
|
+
if (state?.needed === false) return null
|
|
607
|
+
// One row, one action. Nothing actionable and nothing wrong means this host needs no patch at
|
|
608
|
+
// all, so the whole section stays out of the panel instead of offering a no-op install.
|
|
609
|
+
const status = String(state?.status ?? "")
|
|
610
|
+
const applied = status === "applied"
|
|
611
|
+
const broken = /mismatch|unsupported|failed/u.test(status)
|
|
612
|
+
const actionable = applied ? state?.canRestore === true : state?.canInstall === true
|
|
613
|
+
const action = applied ? "restore" : "install"
|
|
614
|
+
const actionKey = applied ? "hostPatch.uninstall" : broken ? "hostPatch.reinstall" : "hostPatch.install"
|
|
599
615
|
return h("div", { key: "web-host-patch", style: styles.group }, [
|
|
600
|
-
h("
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
h("button", { key: "install", type: "button", style: styles.button, disabled: busy || !state?.canInstall, onClick: () => change("install") }, t(busy ? "hostPatch.working" : "hostPatch.install")),
|
|
604
|
-
h("button", { key: "restore", type: "button", style: styles.button, disabled: busy || !state?.canRestore, onClick: () => change("restore") }, t("hostPatch.restore")),
|
|
616
|
+
h("div", { key: "row", className: "dsh-bb-row", style: styles.row }, [
|
|
617
|
+
h("span", { key: "title", role: "status" }, t(state?.surface === "tauri" ? "readiness.hostPatch.tauri" : "readiness.hostPatch") + (state ? ": " + t((state.surface === "tauri" && applied ? "readiness.hostPatch.tauri." : "readiness.hostPatch.") + status.replaceAll(" ", "-")) : "")),
|
|
618
|
+
h("button", { key: "action", type: "button", style: styles.button, disabled: busy || state === null || !actionable, onClick: () => change(action) }, t(busy ? "hostPatch.working" : actionKey)),
|
|
605
619
|
]),
|
|
620
|
+
state?.reason ? h("p", { key: "reason", style: styles.hint }, state.reason) : null,
|
|
606
621
|
notice ? h("p", { key: "notice", role: "status", style: styles.hint }, t(notice)) : null,
|
|
607
622
|
error ? h("p", { key: "error", role: "alert", style: styles.error }, error) : null,
|
|
608
623
|
])
|
|
609
624
|
}
|
|
610
625
|
|
|
611
|
-
function Readiness({ channel } = {}) {
|
|
626
|
+
function Readiness({ channel, experimental = false } = {}) {
|
|
612
627
|
useLocaleVersion()
|
|
613
628
|
const t = translate
|
|
614
629
|
const [runtime, setRuntime] = useState(null)
|
|
@@ -665,7 +680,7 @@ const react = require("react")
|
|
|
665
680
|
const bridgeActive = bridgeJob !== null && bridgeActivePhases.includes(bridgeJob.phase)
|
|
666
681
|
const readBridgeJob = useCallback(async () => {
|
|
667
682
|
try {
|
|
668
|
-
const response = await fetch(
|
|
683
|
+
const response = await fetch(AUTOMATIC_MAINTENANCE_ROUTE, { headers: { accept: "application/json" } })
|
|
669
684
|
if (!response.ok) return
|
|
670
685
|
const data = await response.json()
|
|
671
686
|
if (!alive.current || bridgeSubmitting.current || data.ok !== true || data.protocol !== 1 || !data.job || typeof data.job.id !== "string") return
|
|
@@ -719,8 +734,8 @@ const react = require("react")
|
|
|
719
734
|
}
|
|
720
735
|
}
|
|
721
736
|
|
|
722
|
-
const bridgeAction = async () => {
|
|
723
|
-
const action =
|
|
737
|
+
const bridgeAction = async (requested = "reinstall") => {
|
|
738
|
+
const action = requested
|
|
724
739
|
if (bridgePending.current || busy || bridgeActive) return
|
|
725
740
|
const desktopMenu = () => typeof document.querySelector === "function"
|
|
726
741
|
? document.querySelector("[data-windows-menu]")?.shadowRoot?.querySelector("button") : null
|
|
@@ -737,7 +752,7 @@ const react = require("react")
|
|
|
737
752
|
setBridgeError(null)
|
|
738
753
|
let accepted = false
|
|
739
754
|
try {
|
|
740
|
-
const response = await fetch(
|
|
755
|
+
const response = await fetch(AUTOMATIC_MAINTENANCE_ROUTE, {
|
|
741
756
|
method: "POST",
|
|
742
757
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
743
758
|
body: JSON.stringify({ action, locale: currentLocale }),
|
|
@@ -774,7 +789,18 @@ const react = require("react")
|
|
|
774
789
|
])
|
|
775
790
|
}
|
|
776
791
|
|
|
777
|
-
|
|
792
|
+
// Usable is one colour. CDP readiness, a detected browser that has not been launched yet, and the
|
|
793
|
+
// Web sidebar all mean "this works"; amber stays for genuinely unusable states.
|
|
794
|
+
// `isDesktop`/`carrierIsSidebar` are declared below; inline those two facts here. Usable is one
|
|
795
|
+
// colour: CDP readiness, a detected-but-not-yet-launched browser, and the Web sidebar all mean
|
|
796
|
+
// "this works"; amber stays for genuinely unusable states.
|
|
797
|
+
const desktopNow = typeof globalThis.dshDesktop === "object" && globalThis.dshDesktop !== null
|
|
798
|
+
const sidebarNow = runtime.resolvedCarrier === "sidebar" || runtime.carrier === "sidebar" || runtime.carrier === "bundled"
|
|
799
|
+
const usable = runtime.readiness === "ready" || (!desktopNow && sidebarNow)
|
|
800
|
+
// A detected browser is usable: the plugin launches it over CDP on the first command, so
|
|
801
|
+
// "found but not connected yet" is not a warning — that was the amber badge the user kept seeing.
|
|
802
|
+
|| runtime.systemBrowser?.present === true
|
|
803
|
+
const tone = usable ? styles.badgeOk
|
|
778
804
|
: runtime.readiness === "blocked" ? styles.badgeWarn : styles.badgeUnknown
|
|
779
805
|
const row = (key, label, value) => [
|
|
780
806
|
h("span", { key: `${key}-k`, style: styles.kvKey }, label),
|
|
@@ -799,11 +825,38 @@ const react = require("react")
|
|
|
799
825
|
const systemLabel = runtime.systemBrowser?.checked === true
|
|
800
826
|
? t(runtime.systemBrowser.present ? "readiness.status.systemReady" : "readiness.status.systemMissing").replace("{browser}", systemName)
|
|
801
827
|
: t("readiness.status.checkPending")
|
|
828
|
+
// A third-party desktop shell is never patched (issue #62): no bridge controls, and the system
|
|
829
|
+
// browser is recommended first because it works from this page right now.
|
|
830
|
+
// Which rows and diagnostics belong to the selected carrier: bridge/patch are sidebar-only,
|
|
831
|
+
// native-host registration is the Installed Chrome/Edge path only. Showing every carrier's
|
|
832
|
+
// errors at once is what made all three modes look identically broken.
|
|
833
|
+
// `bundled` is the legacy name of the sidebar carrier, so it counts as sidebar here too.
|
|
834
|
+
const carrierIsSidebar = resolvedCarrier === "sidebar" || runtime.carrier === "sidebar" || runtime.carrier === "bundled"
|
|
835
|
+
const selectedSystemBrowser = runtime.channel === "edge" ? "edge" : runtime.channel === "chrome" ? "chrome" : undefined
|
|
836
|
+
const thirdPartyShell = runtime.shell?.kind === "third-party-shell"
|
|
837
|
+
const shellBrowserName = runtime.shell?.recommendedCarrier === "edge" ? "Edge" : "Chrome"
|
|
802
838
|
const extensionDisconnected = runtime.extension?.state === 'not-connected' || runtime.extension?.state === 'extension-missing'
|
|
839
|
+
// Desktop presence is the only honest signal for the bridge / host-patch / extension rows: a
|
|
840
|
+
// Desktop install on disk is not proof that THIS page is the Desktop shell, and the Web surface
|
|
841
|
+
// has none of those three things. Defined before `stateLabel`, which must not report a bridge
|
|
842
|
+
// state on the Web surface.
|
|
843
|
+
const isDesktop = typeof globalThis.dshDesktop === "object" && globalThis.dshDesktop !== null
|
|
844
|
+
const isSystemCarrier = runtime.channel === 'chrome' || runtime.channel === 'edge'
|
|
845
|
+
// A healthy bridge makes an older terminal failure stale: the record on disk is only replaced
|
|
846
|
+
// when the next maintenance starts, so it must not keep colouring the panel red (issue #142).
|
|
847
|
+
const bridgeHealthy = runtime.bridge.state === "installed" && runtime.bridge.running === true
|
|
848
|
+
// The patch row is about the sidebar carrier only, and only while this Desktop build cannot
|
|
849
|
+
// provide native views by itself: a host that already exposes them needs nothing from us, so
|
|
850
|
+
// the row is absent instead of offering a no-op install.
|
|
851
|
+
const channelIsSidebar = runtime.channel === 'sidebar' || runtime.channel === 'bundled'
|
|
852
|
+
const nativeViewsPresent = typeof globalThis.dshDesktop?.browser?.nativeViews === 'object'
|
|
803
853
|
const stateLabel = resolvedCarrier === "extension" ? extensionDisconnected ? t('extension.notConnected') : runtime.extension?.detail ?? t("readiness.state.blocked")
|
|
804
854
|
: resolvedCarrier === "system" || resolvedCarrier === "cdp" ? systemLabel
|
|
805
855
|
: resolvedCarrier === "sidebar"
|
|
806
|
-
? t(
|
|
856
|
+
? !isDesktop ? t("readiness.status.webSidebar")
|
|
857
|
+
: thirdPartyShell ? t("readiness.status.thirdPartyShell")
|
|
858
|
+
: runtime.shell?.kind === "tauri" ? t(runtime.shell.hostPatch?.status === "applied" ? "readiness.status.tauriReady" : "readiness.status.tauriPatchMissing")
|
|
859
|
+
: t(runtime.bridge.state === "installed"
|
|
807
860
|
? runtime.bridge.running === true ? "readiness.status.bridgeReady"
|
|
808
861
|
: runtime.bridge.running === false ? "readiness.status.bridgeStopped" : "readiness.status.bridgeInstalled"
|
|
809
862
|
: runtime.bridge.state === "stale" ? "readiness.status.bridgeStale"
|
|
@@ -812,6 +865,7 @@ const react = require("react")
|
|
|
812
865
|
: runtime.electron.state === "preparing" ? "readiness.status.bundledPreparing"
|
|
813
866
|
: runtime.electron.state === "failed" ? "readiness.status.bundledFailed" : "readiness.status.bundledMissing")
|
|
814
867
|
const controlsBusy = busy || bridgeBusy !== null || bridgeActive
|
|
868
|
+
// (Desktop detection moved above `stateLabel`: the Web surface must not report bridge states.)
|
|
815
869
|
const extensionAction = async () => {
|
|
816
870
|
setBusy(true)
|
|
817
871
|
try {
|
|
@@ -821,7 +875,7 @@ const react = require("react")
|
|
|
821
875
|
finally { setBusy(false); void read() }
|
|
822
876
|
}
|
|
823
877
|
const extensionButton = h("button", { key: "install-extension", type: "button", style: styles.button, disabled: controlsBusy, onClick: extensionAction }, t('extension.button'))
|
|
824
|
-
const canManageBridge = runtime.bridge.present === true && runtime.bridge.state !== "absent"
|
|
878
|
+
const canManageBridge = isDesktop && runtime.shell?.patchable !== false && runtime.bridge.present === true && runtime.bridge.state !== "absent"
|
|
825
879
|
const extensionUnsupported = runtime.bridge.code === "DESKTOP_MAIN_EXTENSION_UNSUPPORTED"
|
|
826
880
|
const bridgeButtonBusy = bridgeBusy !== null || bridgeActive
|
|
827
881
|
const bridgeButtonStyle = controlsBusy || preparing ? { ...styles.button, cursor: "default", opacity: .6 } : styles.button
|
|
@@ -835,7 +889,7 @@ const react = require("react")
|
|
|
835
889
|
h("span", { key: "title" }, t("readiness.title")),
|
|
836
890
|
h("span", { key: "state", role: "status", style: { ...styles.badge, ...tone } }, stateLabel),
|
|
837
891
|
]),
|
|
838
|
-
runtime.extension ? h("div", { key: "extension" }, [
|
|
892
|
+
experimental && isDesktop && isSystemCarrier && runtime.extension ? h("div", { key: "extension" }, [
|
|
839
893
|
resolvedCarrier !== 'extension' && extensionDisconnected ? h('p', { key: 'fallback-hint', role: 'status', style: styles.hint }, t('extension.notConnected')) : null,
|
|
840
894
|
h("p", { key: "profile", role: "status", style: styles.hint }, [runtime.extension.browser, runtime.extension.profile, runtime.extension.connectionId, runtime.extension.state].filter(Boolean).join(" · ")),
|
|
841
895
|
h("p", { key: "quiet", style: styles.hint }, t("extension.quiet")),
|
|
@@ -847,22 +901,46 @@ const react = require("react")
|
|
|
847
901
|
`${t("readiness.bridge.extension." + runtime.bridge.mainExtension.state)}${runtime.bridge.mainExtension.version ? " · " + runtime.bridge.mainExtension.version : ""}${runtime.bridge.mainExtension.code ? " · " + runtime.bridge.mainExtension.code : ""}`) : null,
|
|
848
902
|
h("div", { key: "row", className: "dsh-bb-row", style: styles.row }, [
|
|
849
903
|
h("span", { key: "title" }, t("readiness.bridge")),
|
|
850
|
-
h("button", { key: "reinstall", type: "button", style: bridgeButtonStyle, disabled: controlsBusy || preparing, "aria-busy": bridgeButtonBusy ? "true" : undefined, onClick: bridgeAction }, t("readiness.bridge.reinstall")),
|
|
851
|
-
|
|
904
|
+
h("button", { key: "reinstall", type: "button", style: bridgeButtonStyle, disabled: controlsBusy || preparing, "aria-busy": bridgeButtonBusy ? "true" : undefined, onClick: () => bridgeAction("reinstall") }, t("readiness.bridge.reinstall")),
|
|
905
|
+
// The only way out when the desktop integration itself is the problem: revert and stop,
|
|
906
|
+
// instead of reinstall-and-repatch (#126). Kept next to reinstall so the row stays honest.
|
|
907
|
+
h("button", { key: "uninstall", type: "button", style: bridgeButtonStyle, disabled: controlsBusy || preparing, onClick: () => bridgeAction("uninstall") }, t("readiness.bridge.uninstall")),
|
|
908
|
+
experimental ? extensionButton : null,
|
|
852
909
|
]),
|
|
853
910
|
h("p", { key: "hint", role: bridgeBusy !== null || bridgeActive ? "status" : undefined, style: styles.hint }, t(bridgeBusy !== null ? "readiness.bridge.working" : bridgeActive ? "readiness.bridge.progressHint" : "readiness.bridge.maintenanceHint")),
|
|
854
911
|
]) : null,
|
|
855
|
-
|
|
856
|
-
|
|
912
|
+
thirdPartyShell ? h("div", { key: "third-party-shell", role: "status" }, [
|
|
913
|
+
h("p", { key: "use-browser", style: styles.hint }, t("readiness.shell.thirdParty.useBrowser").replaceAll("{browser}", shellBrowserName)),
|
|
914
|
+
h("p", { key: "official", style: styles.hint }, t("readiness.shell.thirdParty.official")),
|
|
915
|
+
]) : null,
|
|
916
|
+
experimental && isDesktop && isSystemCarrier && !canManageBridge ? extensionButton : null,
|
|
917
|
+
// Host patch gets its own row, and only when a patch spec matches this Desktop build. A
|
|
918
|
+
// third-party shell or an unsupported version has no patchable target, so the row is absent
|
|
919
|
+
// rather than a dead "unsupported" line.
|
|
920
|
+
isDesktop && channelIsSidebar && !nativeViewsPresent && runtime.shell?.patchable === true ? h("div", { key: "host-patch-row", className: "dsh-bb-row", style: styles.row }, [
|
|
921
|
+
h("span", { key: "title" }, t("readiness.hostPatch")),
|
|
922
|
+
h("span", { key: "state", role: "status", style: styles.hint }, t(runtime.shell?.hostPatch?.status === "applied" ? "readiness.hostPatch.applied" : "readiness.hostPatch.absent")),
|
|
923
|
+
]) : null,
|
|
924
|
+
experimental && extensionMessage ? h('p', { key: 'extension-message', role: 'status', style: styles.hint }, extensionMessage) : null,
|
|
857
925
|
h('p', { key: 'active-carrier', role: 'status', style: styles.hint }, [runtime.resolvedCarrier, runtime.controlledProfile, runtime.fallbackReason, runtime.extension?.registration?.detail].filter(Boolean).join(' · ')),
|
|
858
|
-
|
|
926
|
+
// A failed native-host registration is not the user's fault and not a raw command dump: on
|
|
927
|
+
// Windows it is usually EPERM (the registry write needs elevation). Say what it means and
|
|
928
|
+
// keep the exact command in the diagnostics block below.
|
|
929
|
+
...(selectedSystemBrowser === undefined ? [] : Object.entries(runtime.nativeHostRegistration ?? {})
|
|
930
|
+
.filter(([browser, status]) => experimental && isDesktop && !status.registered && browser === selectedSystemBrowser)
|
|
931
|
+
.map(([browser, status]) => {
|
|
932
|
+
const detail = String(status.detail ?? "")
|
|
933
|
+
const needsAdmin = /EPERM|EACCES|Access is denied/iu.test(detail)
|
|
934
|
+
return h("p", { key: "registration-" + browser, role: "status", style: needsAdmin ? styles.hint : styles.error },
|
|
935
|
+
needsAdmin ? t("readiness.registration.needsAdmin").replaceAll("{browser}", browser) : browser + ': ' + detail)
|
|
936
|
+
})),
|
|
859
937
|
bridgeActive ? h("p", { key: "bridge-progress", role: "status", style: styles.hint }, t(`readiness.bridge.phase.${bridgeJob.phase}`)) : null,
|
|
860
938
|
bridgeJob?.phase === "completed" ? h("p", { key: "bridge-result", role: "status", style: styles.hint }, t("readiness.bridge.installedDone")) : null,
|
|
861
939
|
bridgeJob?.hostPatch ? h("p", { key: "host-patch", role: "status", style: styles.hint },
|
|
862
940
|
`${t("readiness.hostPatch")}: ${t("readiness.hostPatch." + bridgeJob.hostPatch.status.replaceAll(" ", "-"))}`) : null,
|
|
863
|
-
bridgeJob?.phase === "failed" || bridgeJob?.phase === "cancelled" ? h("p", { key: "bridge-job-error", role: "alert", style: styles.error }, t(`readiness.bridge.${bridgeJob.phase}`)) : null,
|
|
864
|
-
bridgeError !== null ? h("p", { key: "bridge-error", role: "alert", style: styles.error }, t(bridgeError.key)) : null,
|
|
865
|
-
runtime.bridge.state === "stale" ? h("p", { key: "bridge-compatibility-error", role: "alert", style: styles.error }, runtime.bridge.detail) : null,
|
|
941
|
+
isDesktop && carrierIsSidebar && !bridgeHealthy && (bridgeJob?.phase === "failed" || bridgeJob?.phase === "cancelled") ? h("p", { key: "bridge-job-error", role: "alert", style: styles.error }, t(`readiness.bridge.${bridgeJob.phase}`)) : null,
|
|
942
|
+
isDesktop && carrierIsSidebar && bridgeError !== null ? h("p", { key: "bridge-error", role: "alert", style: styles.error }, t(bridgeError.key)) : null,
|
|
943
|
+
isDesktop && carrierIsSidebar && runtime.bridge.state === "stale" ? h("p", { key: "bridge-compatibility-error", role: "alert", style: styles.error }, runtime.bridge.detail) : null,
|
|
866
944
|
h("details", { key: "diagnostics", className: "dsh-bb-diagnostics" }, [
|
|
867
945
|
h("summary", { key: "title", style: styles.hint }, t("readiness.details")),
|
|
868
946
|
h("div", { key: "kv", style: styles.kv }, [
|
|
@@ -870,11 +948,21 @@ const react = require("react")
|
|
|
870
948
|
runtime.resolvedCarrier ? row("resolved-carrier", t("readiness.resolvedCarrier"), t(`readiness.carrier.${runtime.resolvedCarrier}`)) : null,
|
|
871
949
|
runtime.systemBrowser?.checked === true ? row("system", t("readiness.system"), systemLabel) : null,
|
|
872
950
|
...row("electron", t("readiness.electron"), t(`readiness.electron.${runtime.electron.state}`)),
|
|
873
|
-
...row("bridge", t("readiness.bridge"), bridgeLabel),
|
|
951
|
+
...(carrierIsSidebar ? row("bridge", t("readiness.bridge"), bridgeLabel) : []),
|
|
874
952
|
]),
|
|
875
953
|
runtime.systemBrowser?.path ? h("code", { key: "system-path", style: styles.mono }, runtime.systemBrowser.path) : null,
|
|
876
954
|
bridgeError?.detail ? h("code", { key: "bridge-error-detail", style: styles.mono }, bridgeError.detail) : null,
|
|
877
|
-
bridgeJobDiagnostic !== "" ? h("code", { key: "bridge-job-detail", style: styles.mono }, bridgeJobDiagnostic) : null,
|
|
955
|
+
carrierIsSidebar && bridgeJobDiagnostic !== "" ? h("code", { key: "bridge-job-detail", style: styles.mono }, bridgeJobDiagnostic) : null,
|
|
956
|
+
// A host peer that does not resolve is what makes four entries stay inactive on a Desktop
|
|
957
|
+
// install that shipped the plugin without its peers (issue #59): name it here so a reporter
|
|
958
|
+
// can paste one line instead of describing the symptom.
|
|
959
|
+
...(runtime.peers ?? []).filter(peer => !peer.resolved).map(peer =>
|
|
960
|
+
h("code", { key: "peer-" + peer.name, style: styles.mono }, `${peer.name}: ${peer.error ?? "unresolved"}`)),
|
|
961
|
+
// The carrier decision trail (issue #106): which browser was adopted last, and why.
|
|
962
|
+
...(runtime.carrierHistory ?? []).map((reason, index) => h("code", { key: "carrier-" + index, style: styles.mono }, reason)),
|
|
963
|
+
// The exact command a human needs when a registration failed (elevation, wrong browser).
|
|
964
|
+
...Object.entries(runtime.nativeHostRegistration ?? {}).filter(([, status]) => !status.registered)
|
|
965
|
+
.map(([browser, status]) => h("code", { key: "registration-detail-" + browser, style: styles.mono }, String(status.detail ?? ""))),
|
|
878
966
|
runtime.electron.state === "failed" || runtime.electron.state === "skipped"
|
|
879
967
|
? h("p", { key: "edetail", style: styles.hint }, runtime.electron.detail) : null,
|
|
880
968
|
runtime.bridge.state === "installed" && runtime.bridge.running === false
|
|
@@ -987,7 +1075,7 @@ const react = require("react")
|
|
|
987
1075
|
const load = useCallback(() => {
|
|
988
1076
|
const revision = ++loadRevision.current
|
|
989
1077
|
setStatus("loading")
|
|
990
|
-
fetch(
|
|
1078
|
+
fetch(`${REFERENCE_LIST_ROUTE}?limit=10`, { headers: { accept: "application/json" } })
|
|
991
1079
|
.then(response => response.ok ? response.json() : Promise.reject(new Error(`HTTP ${response.status}`)))
|
|
992
1080
|
.then(data => {
|
|
993
1081
|
if (!alive.current || loadRevision.current !== revision) return
|
|
@@ -1029,7 +1117,7 @@ const react = require("react")
|
|
|
1029
1117
|
const exportAs = format => {
|
|
1030
1118
|
setExporting(format)
|
|
1031
1119
|
setOutcome(null)
|
|
1032
|
-
fetch(
|
|
1120
|
+
fetch(`${REFERENCE_EXPORT_ROUTE}?format=${encodeURIComponent(format)}`, { headers: { accept: "*/*" } })
|
|
1033
1121
|
.then(async response => {
|
|
1034
1122
|
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
|
1035
1123
|
const blob = await response.blob()
|
|
@@ -1208,6 +1296,10 @@ const react = require("react")
|
|
|
1208
1296
|
const [error, setError] = useState("")
|
|
1209
1297
|
const [busy, setBusy] = useState(false)
|
|
1210
1298
|
const [saved, setSaved] = useState(false)
|
|
1299
|
+
// The main panel is the carrier switch plus CDP readiness — CDP is the baseline that needs no
|
|
1300
|
+
// installation. The extension (drive the user's own browser) is an optional control that lives
|
|
1301
|
+
// in 高级设置 and only renders while that section is open.
|
|
1302
|
+
const [advancedOpen, setAdvancedOpen] = useState(false)
|
|
1211
1303
|
const saving = useRef(false)
|
|
1212
1304
|
const savedTimer = useRef(null)
|
|
1213
1305
|
const alive = useRef(true)
|
|
@@ -1290,15 +1382,14 @@ const react = require("react")
|
|
|
1290
1382
|
...children,
|
|
1291
1383
|
])
|
|
1292
1384
|
const systemBrowser = ["chrome", "edge"].includes(settings.browser.channel)
|
|
1385
|
+
const pluginOwnedProfile = settings.browser.channel === "electron"
|
|
1386
|
+
|| (systemBrowser && settings.browser.systemProfile !== "user")
|
|
1293
1387
|
|
|
1294
1388
|
return h("div", { style: styles.wrap, className: "dsh-bb-settings" }, [
|
|
1295
|
-
selector("browser.channel", settings.browser.channel,
|
|
1296
|
-
options("browser.", ["
|
|
1389
|
+
selector("browser.channel", settings.browser.channel === "bundled" || settings.browser.channel === "auto" ? "sidebar" : settings.browser.channel,
|
|
1390
|
+
options("browser.", ["sidebar", "electron", "chrome", "edge"]),
|
|
1297
1391
|
channel => patch({ browser: { channel } })),
|
|
1298
|
-
|
|
1299
|
-
options("browser.mode.", ["plugin", "user"]), systemProfile => patch({ browser: { systemProfile } })) : null,
|
|
1300
|
-
h(Readiness, { key: "readiness-" + settings.browser.channel + "-" + settings.browser.systemProfile, channel: settings.browser.channel }),
|
|
1301
|
-
h(HostPatchControls, { key: "host-patch" }),
|
|
1392
|
+
h(Readiness, { key: "readiness-" + settings.browser.channel + "-" + settings.browser.systemProfile, channel: settings.browser.channel, experimental: advancedOpen }),
|
|
1302
1393
|
section("ui.title", [
|
|
1303
1394
|
toggle("ui", "quiet", "ui.quiet", "ui.quiet.hint"),
|
|
1304
1395
|
toggle("ui", "autoExpandOnce"),
|
|
@@ -1312,14 +1403,19 @@ const react = require("react")
|
|
|
1312
1403
|
toggle("credentials", "allowRead"),
|
|
1313
1404
|
toggle("actions", "allowCredentialWrite", "actions.allowCredentialWrite", "actions.allowCredentialWrite.hint"),
|
|
1314
1405
|
]),
|
|
1315
|
-
h("details", { key: "advanced", style: styles.group }, [
|
|
1406
|
+
h("details", { key: "advanced", style: styles.group, onToggle: event => setAdvancedOpen(event.currentTarget.open) }, [
|
|
1316
1407
|
h("summary", { key: "title", style: styles.groupTitle }, t("settings.advanced")),
|
|
1408
|
+
// The host patch is a maintenance surface, not a daily control: it lives here with the other
|
|
1409
|
+
// optional plumbing, and it renders nothing when there is nothing actionable.
|
|
1410
|
+
h(HostPatchControls, { key: "host-patch" }),
|
|
1411
|
+
advancedOpen && systemBrowser ? selector("browser.systemProfile", settings.browser.systemProfile ?? "plugin",
|
|
1412
|
+
options("browser.mode.", ["plugin", "user"]), systemProfile => patch({ browser: { systemProfile } })) : null,
|
|
1317
1413
|
toggle("history", "enabled"),
|
|
1318
1414
|
selector("vision.strategy", settings.vision.strategy, [
|
|
1319
1415
|
{ value: "auto", label: t("vision.auto") },
|
|
1320
1416
|
{ value: "nonVisual", label: t("vision.nonVisual") },
|
|
1321
1417
|
], strategy => patch({ vision: { strategy } })),
|
|
1322
|
-
|
|
1418
|
+
pluginOwnedProfile ? toggle("cookies", "persist", "browser.profile", "browser.profile.hint") : null,
|
|
1323
1419
|
systemBrowser && settings.browser.systemProfile !== "user" ? selector("browser.headless", settings.browser.headless ?? "auto",
|
|
1324
1420
|
options("browser.headless.", ["auto", "windowed", "headless"]),
|
|
1325
1421
|
headless => patch({ browser: { headless } }), "browser.headless.hint") : null,
|
|
@@ -1380,6 +1476,13 @@ const react = require("react")
|
|
|
1380
1476
|
return null
|
|
1381
1477
|
}
|
|
1382
1478
|
|
|
1479
|
+
/**
|
|
1480
|
+
* DSH 0.2.2-rc.3 has no `data-sidebar-right-session` markers, so its tab strip is found by its
|
|
1481
|
+
* CSS Modules class. This is the only class-name lookup: every shell with the markers takes
|
|
1482
|
+
* `panelRootsFor` instead.
|
|
1483
|
+
*/
|
|
1484
|
+
const LEGACY_TAB_STRIP_SELECTOR = "[class*=_tabStrip]"
|
|
1485
|
+
|
|
1383
1486
|
/**
|
|
1384
1487
|
* This conversation's own sidebar strip, or null when the shell has not mounted it.
|
|
1385
1488
|
*
|
|
@@ -1389,7 +1492,7 @@ const react = require("react")
|
|
|
1389
1492
|
* the caller can report, instead of a page that never appears.
|
|
1390
1493
|
*/
|
|
1391
1494
|
function tabStripFor(sessionId) {
|
|
1392
|
-
for (const strip of Array.from(document.querySelectorAll(
|
|
1495
|
+
for (const strip of Array.from(document.querySelectorAll(LEGACY_TAB_STRIP_SELECTOR))) {
|
|
1393
1496
|
if (sessionIdOfElement(strip) === sessionId) return strip
|
|
1394
1497
|
}
|
|
1395
1498
|
return null
|
|
@@ -1434,7 +1537,7 @@ const react = require("react")
|
|
|
1434
1537
|
// still reached.
|
|
1435
1538
|
let node = strip
|
|
1436
1539
|
while (node !== null && node !== undefined && node !== document.body) {
|
|
1437
|
-
const foreign = Array.from(node.querySelectorAll(
|
|
1540
|
+
const foreign = Array.from(node.querySelectorAll(LEGACY_TAB_STRIP_SELECTOR))
|
|
1438
1541
|
.some(el => sessionIdOfElement(el) !== sessionId)
|
|
1439
1542
|
if (foreign) break
|
|
1440
1543
|
const found = Array.from(node.querySelectorAll("webview")).filter(view => {
|
|
@@ -1451,7 +1554,7 @@ const react = require("react")
|
|
|
1451
1554
|
function guestStateFor(sessionId, tabId, initializationReader) {
|
|
1452
1555
|
const roots = panelRootsFor(sessionId)
|
|
1453
1556
|
if (roots === undefined ? tabStripFor(sessionId) === null : roots.length === 0) return { panel: false, guestId: null, url: "" }
|
|
1454
|
-
if (
|
|
1557
|
+
if (nativeViews() !== undefined && typeof tabId === "string") {
|
|
1455
1558
|
const page = initializationReader?.current({ sessionId, tabId })
|
|
1456
1559
|
return { panel: true, guestId: page?.guestId ?? null, url: page?.url ?? "", ...page?.generation === undefined ? {} : { nativeState: page } }
|
|
1457
1560
|
}
|
|
@@ -1617,7 +1720,7 @@ const react = require("react")
|
|
|
1617
1720
|
function drainOpenRequest() {
|
|
1618
1721
|
const sessionId = guestSession()
|
|
1619
1722
|
if (typeof sessionId !== "string" || sessionId === "") return
|
|
1620
|
-
fetch(
|
|
1723
|
+
fetch(OPEN_REQUEST_ROUTE, { headers: { accept: "application/json" } })
|
|
1621
1724
|
.then(response => (response.ok ? response.json() : undefined))
|
|
1622
1725
|
.then(body => {
|
|
1623
1726
|
const open = body && body.open
|
|
@@ -1822,7 +1925,7 @@ const react = require("react")
|
|
|
1822
1925
|
return { ok: false, code: "BROWSER_GUEST_CLOSED", reason: "the native tab for this browser view was closed; close or reset the view before retrying", panel: true, guestId: null }
|
|
1823
1926
|
}
|
|
1824
1927
|
const guests = guestsInPanel(sessionId)
|
|
1825
|
-
const hasNativeGuest =
|
|
1928
|
+
const hasNativeGuest = nativeViews() !== undefined && typeof guestId === "string"
|
|
1826
1929
|
const hasCachedGuest = (Number.isInteger(guestId) && guestId > 0) || hasNativeGuest
|
|
1827
1930
|
if (binding === undefined && hasNativeGuest) {
|
|
1828
1931
|
const cached = browsers.find(tab => initializationReader?.current({ sessionId, tabId: tab.id })?.guestId === guestId)
|
|
@@ -1858,7 +1961,7 @@ const react = require("react")
|
|
|
1858
1961
|
try { globalThis.__dshSidebarSessionId = sessionId } catch { /* non-writable global */ }
|
|
1859
1962
|
const before = new Set(tabs.map(tab => tab.id))
|
|
1860
1963
|
try {
|
|
1861
|
-
if (
|
|
1964
|
+
if (nativeViews() !== undefined
|
|
1862
1965
|
&& typeof sidebarRight.openReservedTab === "function") {
|
|
1863
1966
|
const id = globalThis.crypto.randomUUID()
|
|
1864
1967
|
if (!sidebarRight.openReservedTab(sessionId, "browser", id)) return { ok: false, reason: "the shell refused this browser tab reservation" }
|
|
@@ -1947,8 +2050,16 @@ const react = require("react")
|
|
|
1947
2050
|
},
|
|
1948
2051
|
async initializePanel(sessionId, url, options) {
|
|
1949
2052
|
const refuse = (code, reason) => ({ ok: false, code, reason, panel: false, guestId: null })
|
|
1950
|
-
if (
|
|
1951
|
-
|
|
2053
|
+
if (onScreenSession() !== sessionId && !api.isBackgroundRendering(sessionId)) {
|
|
2054
|
+
// Opening the tab and binding the sidebar are two steps in the shell, and the binding lands a
|
|
2055
|
+
// frame or two later. Waiting for it is not the same as switching conversations — the contract
|
|
2056
|
+
// that a tool-driven initialization never changes what the user is looking at still holds; we
|
|
2057
|
+
// only give the shell time to catch up before refusing.
|
|
2058
|
+
for (let attempt = 0; attempt < 4 && onScreenSession() !== sessionId; attempt += 1)
|
|
2059
|
+
await new Promise(resolve => setTimeout(resolve, 250))
|
|
2060
|
+
if (onScreenSession() !== sessionId && !api.isBackgroundRendering(sessionId))
|
|
2061
|
+
return refuse("panel-not-displayed", `the requested conversation is not displayed (sidebar shows ${String(onScreenSession() ?? "nothing")}, asked for ${sessionId}); select it before opening its browser`)
|
|
2062
|
+
}
|
|
1952
2063
|
const reader = initializationReader
|
|
1953
2064
|
if (reader === null || typeof reader.wait !== "function") return refuse("panel-initialization-failed", "the browser initialization subscription is unavailable; reload the plugin client")
|
|
1954
2065
|
const deadline = options.deadline
|
|
@@ -1959,7 +2070,7 @@ const react = require("react")
|
|
|
1959
2070
|
const transaction = { controller, transactionId: options.transactionId }
|
|
1960
2071
|
let placed
|
|
1961
2072
|
const closeNative = () => {
|
|
1962
|
-
if (
|
|
2073
|
+
if (nativeViews() === undefined || typeof placed?.tabId !== "string") return
|
|
1963
2074
|
sidebarRight.closeIn?.(sessionId, placed.tabId)
|
|
1964
2075
|
if (pendingTabs.get(key)?.id === placed.tabId) pendingTabs.delete(key)
|
|
1965
2076
|
}
|
|
@@ -1973,7 +2084,7 @@ const react = require("react")
|
|
|
1973
2084
|
if (controller.signal.aborted) { closeNative(); controller.signal.throwIfAborted() }
|
|
1974
2085
|
if (!answer.ok) return answer
|
|
1975
2086
|
const rendererNavigation = url !== "" && (answer.created || answer.navigating)
|
|
1976
|
-
if (!rendererNavigation && answer.guestId !== null) return
|
|
2087
|
+
if (!rendererNavigation && answer.guestId !== null) return nativeViews() !== undefined
|
|
1977
2088
|
? { ...answer, nativeState: reader.current({ sessionId, tabId: answer.tabId }) } : answer
|
|
1978
2089
|
if (typeof answer.tabId !== "string") return refuse("panel-initialization-failed", "the shell did not acknowledge its native tab identity")
|
|
1979
2090
|
const receipt = await reader.wait({ sessionId, tabId: answer.tabId, url }, controller.signal)
|
|
@@ -2095,7 +2206,7 @@ const react = require("react")
|
|
|
2095
2206
|
// causes — the shell has mounted no sidebar for this conversation (nothing this side can
|
|
2096
2207
|
// do), or it writes its session id somewhere this lookup does not read (fixable) — and a
|
|
2097
2208
|
// refusal that says only "not mounted" cannot tell them apart.
|
|
2098
|
-
const strips = Array.from(document.querySelectorAll(
|
|
2209
|
+
const strips = Array.from(document.querySelectorAll(LEGACY_TAB_STRIP_SELECTOR))
|
|
2099
2210
|
return {
|
|
2100
2211
|
ok: false,
|
|
2101
2212
|
reason: "this conversation's sidebar is not mounted, so a panel cannot be opened in it",
|
|
@@ -2151,7 +2262,7 @@ const react = require("react")
|
|
|
2151
2262
|
closePanelGuest(sessionId, guestId) {
|
|
2152
2263
|
const refuse = reason => ({ ok: false, reason, closed: 0 })
|
|
2153
2264
|
if (typeof sessionId !== "string" || !/^session-/.test(sessionId)) return refuse("a conversation id is required")
|
|
2154
|
-
if (typeof guestId === "string" &&
|
|
2265
|
+
if (typeof guestId === "string" && nativeViews() !== undefined) {
|
|
2155
2266
|
const tabs = sidebarRight.tabsIn(sessionId)
|
|
2156
2267
|
const tab = tabs.find(tab => tab.kind === "browser" && initializationReader?.current({ sessionId, tabId: tab.id })?.guestId === guestId)
|
|
2157
2268
|
if (tab === undefined || typeof sidebarRight.closeIn !== "function") return refuse("the native guest does not belong to this conversation")
|
|
@@ -62,13 +62,10 @@ export class StartPageController implements HostObservable<StartPageSnapshot> {
|
|
|
62
62
|
private disposed = false
|
|
63
63
|
private readonly createId: () => string
|
|
64
64
|
private readonly applicationOrigin: string
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* @param form - the shared `browser-startpage` configuration form.
|
|
68
|
-
* @param options - current application origin and an optional id source.
|
|
69
|
-
*/
|
|
70
|
-
constructor(private readonly form: ConfigForm<BrowserStartPagePreferences>,
|
|
65
|
+
private readonly form: ConfigForm<BrowserStartPagePreferences>
|
|
66
|
+
constructor(form: ConfigForm<BrowserStartPagePreferences>,
|
|
71
67
|
options: { readonly applicationOrigin: string; readonly createId?: () => string }) {
|
|
68
|
+
this.form = form
|
|
72
69
|
this.applicationOrigin = options.applicationOrigin
|
|
73
70
|
this.createId = options.createId ?? (() => globalThis.crypto.randomUUID())
|
|
74
71
|
this.unsubscribe = form.subscribe(() => { this.publish() })
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
ICON_REGULAR_STROKE,
|
|
13
13
|
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
14
14
|
import type { InjectFace, PropsLocale, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots'
|
|
15
|
+
import type { SIDEBAR_BROWSER_LOCALE_NS } from '../locales.ts'
|
|
15
16
|
import type { BrowserInjected } from '../browser/BrowserController.ts'
|
|
16
17
|
import type { BrowserInitFailure } from '../browser/initialization.ts'
|
|
17
18
|
import { emptyBrowserFrame } from '../browser/BrowserFrame.ts'
|
|
@@ -43,7 +44,7 @@ function SandboxPolicyIcon({ sandboxed }: { readonly sandboxed: boolean }): Reac
|
|
|
43
44
|
/** Browser body props assembled by the tab seat. */
|
|
44
45
|
export type BrowserBodyProps = PropsRuntime<'sidebar.right.pane.tab'>
|
|
45
46
|
& PropsStore<BrowserStore>
|
|
46
|
-
& PropsLocale<
|
|
47
|
+
& PropsLocale<typeof SIDEBAR_BROWSER_LOCALE_NS>
|
|
47
48
|
& InjectFace<BrowserInjected>
|
|
48
49
|
|
|
49
50
|
function useBrowserDraft(url: string | undefined, revision: number): readonly [string, (value: string) => void, () => void] {
|