fix(dsh): restore native file tools and official loading UI
Core regression / Python core and release configuration (push) Successful in 20s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s

This commit is contained in:
阿白叔 committed 2026-11-04 19:05:21 +08:00
1 parent 1340f6c233
commit 705c15eb93
19 files changed
+398 -42

No files matched your search

@@ -6,7 +6,7 @@ import codecs
from pathlib import Path
from PySide6.QtCore import QProcess, QProcessEnvironment, QTimer, QUrl, Signal, Qt
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineProfile, QWebEngineSettings
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineProfile, QWebEngineSettings, QWebEngineScript
from PySide6.QtWebEngineWidgets import QWebEngineView
from PySide6.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget
from shiboken6 import isValid
@@ -17,9 +17,10 @@ from ...dsh.snapshot import TaskSnapshot
class LocalHarnessPage(QWebEnginePage):
allowed_port = None
loading_url = QUrl()
def acceptNavigationRequest(self, url, kind, is_main_frame):
return url.scheme() == 'about' or (url.scheme() == 'http' and url.host() == '127.0.0.1' and url.port() == self.allowed_port)
return (url == self.loading_url and url.scheme() == 'file') or url.scheme() == 'about' or (url.scheme() == 'http' and url.host() == '127.0.0.1' and url.port() == self.allowed_port)
def createWindow(self, _kind):
return None
@@ -64,10 +65,17 @@ class NativeHarnessView(QWidget):
self.profile.setCachePath(str(self.data_root / 'browser/cache'))
self.profile.setPersistentCookiesPolicy(QWebEngineProfile.PersistentCookiesPolicy.NoPersistentCookies)
self.web.setPage(LocalHarnessPage(self.profile, self.web))
bootstrap = QWebEngineScript()
bootstrap.setName('Official Harness loading until local runtime is ready')
bootstrap.setInjectionPoint(QWebEngineScript.InjectionPoint.DocumentCreation)
bootstrap.setWorldId(QWebEngineScript.ScriptWorldId.MainWorld)
bootstrap.setSourceCode("if(location.protocol==='file:'){globalThis.__DSH_BOOT_READY__={promise:new Promise(()=>{})};}")
self.web.page().scripts().insert(bootstrap)
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.JavascriptCanOpenWindows, False)
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, False)
self.status = QLabel('正在启动 DSH助手…')
self.status.setWordWrap(True)
self.status.hide()
self.retry = QPushButton('重试启动')
self.retry.hide()
self.retry.clicked.connect(self.start)
@@ -140,9 +148,9 @@ class NativeHarnessView(QWidget):
return
self._stopping = False
self._started = False
self.status.setText('正在加载 DeepSeek Harness 官方界面…')
self.status.show()
self.status.hide()
self.retry.hide()
self._show_official_loading(root)
env = QProcessEnvironment()
try:
for key, value in launch_environment(self.data_root).items():
@@ -156,7 +164,16 @@ class NativeHarnessView(QWidget):
self.process.setProgram(node)
self.process.setArguments([str(root / 'start.mjs')])
self.process.start()
self.timeout.start(120000)
# Cold startup of the official file plugins can exceed two minutes.
self.timeout.start(300000)
def _show_official_loading(self, root: Path):
frontend = root / 'node_modules/@deepseek-ai/dsh-web-frontend/dist/index.html'
if frontend.is_file():
self.web.page().loading_url = QUrl.fromLocalFile(str(frontend.resolve()))
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, True)
self.web.show()
self.web.load(self.web.page().loading_url)
def _reset_output(self):
self._buffer = ''
@@ -187,6 +204,7 @@ class NativeHarnessView(QWidget):
self.web.page().allowed_port = url.port()
self.timeout.stop()
self.status.hide()
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, False)
self.web.load(url)
self.ready.emit()
queued, self._diagnosis_queue = self._diagnosis_queue, []
@@ -220,6 +238,7 @@ class NativeHarnessView(QWidget):
self.timeout.stop()
self.status.setText(text)
self.status.show()
self.web.hide()
self.retry.show()
def _finished(self, *_):