fix(ui): join cleanup completion with explicit force confirmation
Core regression / Python core and release configuration (push) Successful in 42s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 35s
Core regression / JavaScript syntax (pull_request) Successful in 3s

This commit is contained in:
阿白叔 committed 2026-11-08 20:02:42 +08:00
1 parent 086e0ebb61
commit 189ddc238b
3 files changed
+69 -16

No files matched your search

@@ -890,7 +890,26 @@ class TrialTaskCenterWindow(MaterialMainWindow):
show_cad_dialogs(self)
self._update_gates()
return
force_confirmed = False
cleanup_finished = False
force_started = False
def start_force_if_ready():
nonlocal force_started
if force_confirmed and cleanup_finished and not force_started and not self._close_pending:
force_started = True
self._run_async(lambda: self.service.force_pending_owned_resources(confirmed=True),
forced, self.run_panel.cleanup_resources_button)
def after_cleanup():
nonlocal cleanup_finished
cleanup_finished = True
start_force_if_ready()
def forced(remaining):
self._resource_status.refresh()
self._set_operator_message('仍有资源未能确认释放,请保留诊断。' if remaining else
'自有残留资源已释放;相关工程仍须核验后恢复。', 'warning')
self._update_gates()
def done(pending):
nonlocal force_confirmed
hints = tuple(dict.fromkeys(row['resolution_hint'] for row in pending if row.get('resolution_hint')))
self._set_operator_message(
'\n'.join(hints) if hints else '后台资源仍待清理,请保留诊断记录后重试。' if pending else '后台资源已释放,可以继续。',
@@ -903,18 +922,11 @@ class TrialTaskCenterWindow(MaterialMainWindow):
'可能存在未保存或部分保存的结果。中断证据会保留,相关工程必须先核验,不能直接再次替换。',
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
QMessageBox.StandardButton.No) == QMessageBox.StandardButton.Yes:
def forced(remaining):
self._resource_status.refresh()
self._set_operator_message('仍有资源未能确认释放,请保留诊断。' if remaining else
'自有残留资源已释放;相关工程仍须核验后恢复。', 'warning')
self._update_gates()
# The cleanup worker still occupies _workers during this result
# callback. Submit after its finished signal releases the lane.
QTimer.singleShot(0, lambda: self._run_async(
lambda: self.service.force_pending_owned_resources(confirmed=True), forced,
self.run_panel.cleanup_resources_button))
force_confirmed = True
# A modal question can deliver finished before returning Yes.
start_force_if_ready()
self._run_async(self.service.cleanup_batch_resources, done,
self.run_panel.cleanup_resources_button)
self.run_panel.cleanup_resources_button, on_finished=after_cleanup)
def _startup_resource_recheck(self):
if self._closed:
@@ -1247,7 +1259,7 @@ class TrialTaskCenterWindow(MaterialMainWindow):
self._set_operator_message(state.message)
def _run_async(self, operation, callback, button=None, *, expected_task_id=None,
retain_result=False, operation_area='', **_unused):
retain_result=False, operation_area='', on_finished=None, **_unused):
if (self._workers or self._closed or (self._dsh_task_creation is not None and self._dsh_task_creation.dialog is not None)
or (self._dsh_lifecycle is not None and self._dsh_lifecycle.dialog is not None)
or (self._dsh_operations is not None and self._dsh_operations.dialog is not None)):
@@ -1311,6 +1323,8 @@ class TrialTaskCenterWindow(MaterialMainWindow):
QTimer.singleShot(0, self.close)
if not self._closed:
self._update_gates()
if on_finished is not None and not self._close_pending:
on_finished()
worker.signals.succeeded.connect(succeeded)
worker.signals.failed.connect(failed)
worker.signals.finished.connect(finished)