fix: bound task handoff and preserve native writer ownership

This commit is contained in:
阿白叔 committed 2026-11-16 18:57:36 +08:00
1 parent 0440b2efbf
commit ddff6bd857
18 files changed
+1397 -118

No files matched your search

+27
View File
@@ -53,6 +53,14 @@ def _cancel_target(snapshot):
return None
def _tip_target(snapshot):
from .dialog_agent import DialogActionExecutor
if snapshot.title != 'Tip of the Day' or snapshot.window_class != '#32770':
return None
target = DialogActionExecutor._target(snapshot, {'control_id': 1})
return target if target is not None and target.class_name == 'Button' else None
def close_failed_startup(job, pcb_pid, *, baseline_pids=(), emit=lambda **event: None,
timeout_seconds=20, launcher_process=None):
"""Normally close our empty PCB after a diagnosed database startup failure.
@@ -84,6 +92,7 @@ def close_failed_startup(job, pcb_pid, *, baseline_pids=(), emit=lambda **event:
declined_hwnd = None
declined_kind = None
cancelled_open = False
dismissed_tips = set()
while True:
records = [r for r in _process_details('ExpeditionPCB.exe') if r[0] == pcb_pid]
if not records:
@@ -121,6 +130,24 @@ def close_failed_startup(job, pcb_pid, *, baseline_pids=(), emit=lambda **event:
if declined_hwnd is not None and declined_hwnd not in windows:
cancelled_open = True
result['cancelled_prompt'] = declined_kind
dismissed = False
for hwnd in windows:
if hwnd in dismissed_tips or win32gui.GetClassName(hwnd) != '#32770':
continue
snapshot = _startup_snapshot(hwnd, pcb_pid)
target = _tip_target(snapshot)
if target is None:
continue
current = _startup_snapshot(hwnd, pcb_pid)
if current != snapshot or _tip_target(current) != target:
raise ValueError('STARTUP_TIP_CHANGED')
win32gui.PostMessage(target.handle, win32con.BM_CLICK, 0, 0)
dismissed_tips.add(hwnd)
dismissed = True
emit(stage='startup_tip_dismissed', pcb_pid=pcb_pid, hwnd=hwnd)
break
if dismissed:
continue # Prove the Tip disappeared; it does not prove a cancelled open.
if declined_hwnd is None:
for hwnd in windows:
if win32gui.GetClassName(hwnd) != '#32770':