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
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:
1 parent
1340f6c233
commit
705c15eb93
19 files changed
+398
-42
No files matched your search
@@ -33,6 +33,7 @@ def main():
|
||||
parser.add_argument('--provider-config', type=Path)
|
||||
parser.add_argument('--live-model', action='store_true')
|
||||
parser.add_argument('--model-settings-check', action='store_true', help='Create an isolated custom provider using a local model-list fixture')
|
||||
parser.add_argument('--file-check', action='store_true', help='Pick and upload a real local text file and ZIP in the official UI')
|
||||
parser.add_argument('--incident', action='store_true', help='Inject a read-only controlled failure and verify automatic diagnosis and Git escalation')
|
||||
parser.add_argument('--outbox-only', action='store_true', help='Verify failed publication stays in local outbox without creating another real issue')
|
||||
parser.add_argument('--without-git', action='store_true', help='Simulate a client with no Git credentials or executable')
|
||||
@@ -40,6 +41,13 @@ def main():
|
||||
args = parser.parse_args()
|
||||
output = args.output.resolve()
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
if args.file_check:
|
||||
import zipfile
|
||||
fixtures = output / 'file-fixtures'
|
||||
fixtures.mkdir(exist_ok=True)
|
||||
(fixtures / 'dsh-upload.txt').write_text('DSH_UPLOAD_CONTENT_中文\n', encoding='utf8')
|
||||
with zipfile.ZipFile(fixtures / 'dsh-upload.zip', 'w', zipfile.ZIP_DEFLATED) as archive:
|
||||
archive.writestr('中文目录/说明.txt', 'DSH_ZIP_UPLOAD_CONTENT_中文')
|
||||
data = output / ('data-' + time.strftime('%Y%m%d-%H%M%S'))
|
||||
project_root = output / 'source-projects'
|
||||
source_hashes = {}
|
||||
@@ -65,14 +73,16 @@ def main():
|
||||
os.environ.pop('QT_QPA_PLATFORM', None)
|
||||
from PySide6.QtCore import QTimer, Qt
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox, QDialogButtonBox
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox, QDialogButtonBox, QFileDialog, QLineEdit
|
||||
if args.file_check:
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_DontUseNativeDialogs)
|
||||
from dx_productivity.trial_task_center import application
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
from dx_productivity.trial_task_center.ui.dsh_task_creation import DshTaskCreationDialog
|
||||
|
||||
report = {'driver': 'Qt QTest mouse clicks + Chromium CDP Input events', 'checks': []}
|
||||
state = {'phase': 'select', 'child': None, 'creation_step': 'input',
|
||||
'deadline': time.monotonic() + (420 if args.incident else 300 if args.create_task else 240 if args.live_model else 150)}
|
||||
'deadline': time.monotonic() + (600 if args.file_check else 420 if args.incident else 300 if args.create_task else 240 if args.live_model else 150)}
|
||||
|
||||
def build_window(service):
|
||||
if not args.create_task:
|
||||
@@ -91,6 +101,8 @@ def main():
|
||||
|
||||
def failed(error):
|
||||
report.update(status='failed', error=type(error).__name__ + ': ' + str(error))
|
||||
if window._dsh_view is not None:
|
||||
report['runtimeStatus'] = window._dsh_view.status.text()
|
||||
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
|
||||
child = state['child']
|
||||
if child and child.poll() is None:
|
||||
@@ -102,7 +114,43 @@ def main():
|
||||
try:
|
||||
if time.monotonic() > state['deadline']:
|
||||
raise TimeoutError('Native desktop acceptance timed out')
|
||||
if state['phase'] == 'ready' and window._dsh_view is not None and window._dsh_view.retry.isVisible():
|
||||
from dx_productivity.dsh.provider_config import load_provider
|
||||
key = load_provider(data / 'dsh').get('DSH_API_KEY', '')
|
||||
diagnostic = window._dsh_view.last_error
|
||||
if key:
|
||||
diagnostic = diagnostic.replace(key, '[redacted]')
|
||||
report['startupDiagnostic'] = diagnostic[-8000:]
|
||||
raise RuntimeError(window._dsh_view.status.text())
|
||||
modal = QApplication.activeModalWidget()
|
||||
if state['phase'] == 'ready' and window._dsh_view is not None and not report.get('officialLoadingPassed') and not state.get('checkingLoading'):
|
||||
state['checkingLoading'] = True
|
||||
def loading_ready(value):
|
||||
state['checkingLoading'] = False
|
||||
if value and not report.get('officialLoadingPassed'):
|
||||
assert not window._dsh_view.status.isVisible()
|
||||
report['officialLoadingPassed'] = True
|
||||
state['loadingCapture'] = subprocess.Popen(['node', str(REPO / 'tools/dsh_cdp.mjs'),
|
||||
'--capture-loading', str(args.port), str(output / 'official-loading.png')],
|
||||
cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == 'nt' else 0)
|
||||
report['checks'].append('unmodified official frontend HARNESS loading spinner rendered before local runtime readiness')
|
||||
window._dsh_view.web.page().runJavaScript("!!document.querySelector('[data-dsh-boot] [data-dsh-boot-spinner]')", loading_ready)
|
||||
if args.file_check and isinstance(modal, QFileDialog) and not modal.property('dshAcceptancePicked'):
|
||||
modal.setProperty('dshAcceptancePicked', True)
|
||||
selected = (output / 'file-picker-request.json')
|
||||
assert selected.is_file(), 'Unexpected file picker'
|
||||
files = json.loads(selected.read_text(encoding='utf8'))
|
||||
edit = modal.findChild(QLineEdit, 'fileNameEdit')
|
||||
assert edit is not None
|
||||
QApplication.clipboard().setText(' '.join('"' + str(Path(f).resolve()) + '"' for f in files))
|
||||
edit.setFocus()
|
||||
QTest.keyClick(edit, Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier)
|
||||
QTest.keyClick(edit, Qt.Key.Key_V, Qt.KeyboardModifier.ControlModifier)
|
||||
buttons = modal.findChild(QDialogButtonBox)
|
||||
assert buttons is not None
|
||||
QTest.mouseClick(buttons.button(QDialogButtonBox.StandardButton.Open), Qt.MouseButton.LeftButton)
|
||||
report['checks'].append('selected owned text and ZIP fixtures in the real Qt file picker and clicked Open')
|
||||
if args.create_task and isinstance(modal, DshTaskCreationDialog):
|
||||
if state['creation_step'] == 'input':
|
||||
assert modal.name_edit.text() == 'DSH对话换料验收'
|
||||
@@ -124,6 +172,7 @@ def main():
|
||||
assert window.task_list.list.count() == 0
|
||||
click_navigation(window.dsh_action)
|
||||
state['phase'] = 'ready'
|
||||
state['runtimeWaitStarted'] = time.monotonic()
|
||||
report['checks'].append('opened native assistant from an empty task center')
|
||||
elif state['phase'] == 'select' and window.task_list.list.count() and not window._task_query.busy:
|
||||
item = window.task_list.list.item(0)
|
||||
@@ -142,13 +191,18 @@ def main():
|
||||
assert window.content_stack.currentWidget() is window._dsh_view
|
||||
report['checks'].append('clicked task row and opened DSH with one click on the right navigation item')
|
||||
state['phase'] = 'ready'
|
||||
state['runtimeWaitStarted'] = time.monotonic()
|
||||
elif state['phase'] == 'ready' and window._dsh_view is not None and window._dsh_view._started:
|
||||
if 'runtimeWaitStarted' in state:
|
||||
report['runtimeWaitSeconds'] = round(time.monotonic() - state['runtimeWaitStarted'], 2)
|
||||
script = 'verify_dsh_task_creation_ui.mjs' if args.create_task else 'verify_dsh_incident_ui.mjs' if args.incident else 'verify_dsh_native_ui.mjs'
|
||||
command = ['node', str(REPO / 'tools' / script), str(output), str(args.port), '--confirm-cancel']
|
||||
if args.live_model:
|
||||
command.append('--live-model')
|
||||
if args.model_settings_check:
|
||||
command.append('--model-settings-check')
|
||||
if args.file_check:
|
||||
command.append('--file-check')
|
||||
if args.outbox_only:
|
||||
command.append('--outbox-only')
|
||||
state['child'] = subprocess.Popen(command, cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
@@ -215,6 +269,14 @@ def main():
|
||||
|
||||
application._load_window = lambda: build_window
|
||||
code = application.main(['--data-root', str(data)])
|
||||
capture = state.get('loadingCapture')
|
||||
if capture is not None:
|
||||
try:
|
||||
capture.communicate(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
capture.terminate()
|
||||
capture.communicate(timeout=5)
|
||||
report['officialLoadingScreenshot'] = capture.returncode == 0
|
||||
if code or report.get('status') != 'passed':
|
||||
print(json.dumps(report, ensure_ascii=False))
|
||||
return 1
|
||||
@@ -226,8 +288,8 @@ def main():
|
||||
audit_file = data / 'dsh/harness-home/task-tool-audit.jsonl'
|
||||
audit = [json.loads(line) for line in audit_file.read_text(encoding='utf8').splitlines()] if audit_file.is_file() else []
|
||||
report['modelToolCalls'] = audit
|
||||
expected_tool = 'dx_task_create' if args.create_task else 'dx_task_snapshot'
|
||||
report['modelToolSucceeded'] = any(row['name'] == expected_tool and row['is_error'] is False for row in audit)
|
||||
expected_tools = ['read', 'extract_zip'] if args.file_check else ['dx_task_create' if args.create_task else 'dx_task_snapshot']
|
||||
report['modelToolSucceeded'] = all(any(row['name'] == name and row['is_error'] is False for row in audit) for name in expected_tools)
|
||||
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
|
||||
print(json.dumps(report, ensure_ascii=True))
|
||||
return 0 if report['cleanShutdown'] and not report['uncaughtErrors'] and not report['unexpectedUiErrors'] and (not (args.live_model or args.incident or args.create_task) or report['modelToolSucceeded']) else 1
|
||||
|
||||
Reference in new issue
Block a user