merge: reconcile DSH receipts with updated target lifecycle
This commit is contained in:
commit
4aaebcb65a
8 files changed
+274
-9
No files matched your search
@@ -47,13 +47,13 @@ class DshAutomation(QObject):
|
||||
except (OSError, ValueError, KeyError):
|
||||
continue
|
||||
|
||||
def enqueue(self, task_id, issue_code, message, *, execution_authorized=False, run_id='observation'):
|
||||
def enqueue(self, task_id, issue_code, message, *, execution_authorized=False, run_id='observation', stop_event=None):
|
||||
# Offscreen UI unit tests have no Chromium surface or local provider.
|
||||
if QApplication.platformName().casefold() == 'offscreen':
|
||||
return False
|
||||
if issue_code == 'operation_cancelled' or not task_id:
|
||||
return False
|
||||
item = (task_id, issue_code, message, execution_authorized, run_id)
|
||||
item = (task_id, issue_code, message, execution_authorized, run_id, stop_event)
|
||||
identity = (task_id, issue_code, run_id)
|
||||
if identity in self.seen:
|
||||
return True
|
||||
@@ -70,7 +70,7 @@ class DshAutomation(QObject):
|
||||
or (w._dsh_task_creation and w._dsh_task_creation.dialog) or w._dsh_operations.busy):
|
||||
QTimer.singleShot(200, self._drain)
|
||||
return
|
||||
task_id, code, message, authorized, run_id = self.pending.pop(0)
|
||||
task_id, code, message, authorized, run_id, original_stop = self.pending.pop(0)
|
||||
self.latest = {}
|
||||
self._native_unavailable = False
|
||||
try:
|
||||
@@ -83,7 +83,9 @@ class DshAutomation(QObject):
|
||||
view.diagnosis_event.connect(self._diagnosis_event)
|
||||
view.stopped.connect(self._runtime_stopped)
|
||||
self._connected_view = view
|
||||
stop = StopControl()
|
||||
# Carry the original run's stop/force intent through the asynchronous
|
||||
# handoff, including pauses requested after enqueue but before drain.
|
||||
stop = original_stop if original_stop is not None else StopControl()
|
||||
# The same worker gate reserves the mutation lane throughout diagnosis.
|
||||
w._batch_stop = stop
|
||||
w._active_quick_run_task_id = task_id
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import codecs
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QProcess, QProcessEnvironment, QTimer, QUrl, Signal
|
||||
@@ -47,7 +48,7 @@ class NativeHarnessView(QWidget):
|
||||
self._diagnosis_queue = []
|
||||
self._pending_context = None
|
||||
self._context_attempts = 0
|
||||
self._buffer = ''
|
||||
self._reset_output()
|
||||
self._started = False
|
||||
self._stopping = False
|
||||
self.last_error = ''
|
||||
@@ -125,6 +126,7 @@ class NativeHarnessView(QWidget):
|
||||
def start(self):
|
||||
if self.is_running:
|
||||
return
|
||||
self._reset_output()
|
||||
if self.context is None and self._pending_context is None:
|
||||
self.bind(TaskSnapshot('', 'observe'))
|
||||
root = integration_root()
|
||||
@@ -133,7 +135,6 @@ class NativeHarnessView(QWidget):
|
||||
return
|
||||
self._stopping = False
|
||||
self._started = False
|
||||
self._buffer = ''
|
||||
self.status.setText('正在加载 DeepSeek Harness 官方界面…')
|
||||
self.status.show()
|
||||
self.retry.hide()
|
||||
@@ -152,8 +153,13 @@ class NativeHarnessView(QWidget):
|
||||
self.process.start()
|
||||
self.timeout.start(120000)
|
||||
|
||||
def _reset_output(self):
|
||||
self._buffer = ''
|
||||
self._stdout_decoder = codecs.getincrementaldecoder('utf8')('replace')
|
||||
self._stderr_decoder = codecs.getincrementaldecoder('utf8')('replace')
|
||||
|
||||
def _stdout(self):
|
||||
self._buffer += bytes(self.process.readAllStandardOutput()).decode('utf8', 'replace')
|
||||
self._buffer += self._stdout_decoder.decode(bytes(self.process.readAllStandardOutput()))
|
||||
lines = self._buffer.split('\n')
|
||||
self._buffer = lines.pop()
|
||||
for line in lines:
|
||||
@@ -188,7 +194,7 @@ class NativeHarnessView(QWidget):
|
||||
self.action_requested.emit(request)
|
||||
|
||||
def _stderr(self):
|
||||
self.last_error = (self.last_error + bytes(self.process.readAllStandardError()).decode('utf8', 'replace'))[-12000:]
|
||||
self.last_error = (self.last_error + self._stderr_decoder.decode(bytes(self.process.readAllStandardError())))[-12000:]
|
||||
|
||||
def _failed(self, text):
|
||||
if self._stopping or not isValid(self.status):
|
||||
|
||||
@@ -47,6 +47,7 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
self._dsh_run_id = 'observation'
|
||||
self._dsh_live_run = {'active': False}
|
||||
self._dsh_last_execution = {}
|
||||
self._dsh_run_stop = None
|
||||
self._dsh_authorized_tasks = set()
|
||||
self.task_center_action = QAction('任务中心', self)
|
||||
self.task_center_action.triggered.connect(lambda: self.content_stack.setCurrentIndex(0))
|
||||
@@ -764,6 +765,7 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
from uuid import uuid4
|
||||
self._dsh_run_id = uuid4().hex
|
||||
self._batch_stop = StopControl()
|
||||
self._dsh_run_stop = self._batch_stop
|
||||
self._active_quick_run_task_id = task_id
|
||||
self._run_started_at = time.time()
|
||||
self._quick_run_elapsed.start()
|
||||
@@ -775,6 +777,11 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
self._message = ''
|
||||
|
||||
def _finish_run(self):
|
||||
# Completion may report paused=False after the final failed item.
|
||||
# Keep the original stop/force object for incidents from this run;
|
||||
# only a newly authorized _begin_run replaces it with a fresh control.
|
||||
if self._batch_stop is not None:
|
||||
self._dsh_run_stop = self._batch_stop
|
||||
self._quick_run_timer.stop()
|
||||
self._feedback_query.invalidate()
|
||||
self._active_quick_run_task_id = None
|
||||
@@ -1224,4 +1231,5 @@ class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
from .dsh_automation import DshAutomation
|
||||
self._dsh_automation = DshAutomation(self)
|
||||
return self._dsh_automation.enqueue(task_id, issue_code, message,
|
||||
execution_authorized=task_id in self._dsh_authorized_tasks, run_id=self._dsh_run_id)
|
||||
execution_authorized=task_id in self._dsh_authorized_tasks, run_id=self._dsh_run_id,
|
||||
stop_event=self._batch_stop if self._batch_stop is not None else self._dsh_run_stop)
|
||||
Reference in new issue
Block a user