feat(update): integrate managed installs and recoverable in-app updates (#6168)
Add owner-aware Stable and Preview updates with explicit consent, verified release plans, protected process handoff and bounded service recovery. Keep configuration and conversations separate from program rollback. Include the compact About controls, Windows long-path support, native package recovery checks and optional macOS Dock lifecycle integration. Preserve documented guidance for installations owned by other managers. This code integration does not publish packages, enable signing or advance the public update channel. Co-authored-by: chengyongru <61816729+chengyongru@users.noreply.github.com>
This commit is contained in:
1 parent
76da55994b
commit
fbb61a373f
216 files changed
+27948
-1084
No files matched your search
@@ -19,6 +19,8 @@ from nanobot.webui.settings_services import (
|
||||
|
||||
|
||||
class _Flow:
|
||||
has_pending_work = False
|
||||
|
||||
def __init__(self, *, expired: bool = False) -> None:
|
||||
self.expired = expired
|
||||
self.cancel_count = 0
|
||||
@@ -26,6 +28,12 @@ class _Flow:
|
||||
def cancel(self) -> None:
|
||||
self.cancel_count += 1
|
||||
|
||||
def wait_closed(self) -> None:
|
||||
pass
|
||||
|
||||
def complete(self, response=None):
|
||||
return None
|
||||
|
||||
|
||||
def _gateway(config_path: Path, workspace: Path):
|
||||
return build_gateway_services(
|
||||
@@ -243,3 +251,87 @@ def test_oauth_registry_preserves_expiry_capacity_completion_and_cancel() -> Non
|
||||
registry.clear("openai_codex")
|
||||
assert replacement.cancel_count == 1
|
||||
assert registry.get("openai_codex", "replacement") is None
|
||||
|
||||
|
||||
def test_oauth_registry_capacity_counts_cancelled_workers_until_exit():
|
||||
release = threading.Event()
|
||||
cancelled = threading.Event()
|
||||
|
||||
class ThreadFlow(_Flow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.thread = threading.Thread(target=lambda: release.wait(3))
|
||||
|
||||
@property
|
||||
def has_pending_work(self):
|
||||
return self.thread.is_alive()
|
||||
|
||||
def cancel(self):
|
||||
cancelled.set()
|
||||
|
||||
def wait_closed(self):
|
||||
self.thread.join()
|
||||
|
||||
registry = WebUIOAuthFlowRegistry(max_flows=1)
|
||||
flow = ThreadFlow()
|
||||
registry.register("github_copilot", "first", flow)
|
||||
flow.thread.start()
|
||||
replacement = _Flow()
|
||||
try:
|
||||
with pytest.raises(RuntimeError, match="still stopping"):
|
||||
registry.register("github_copilot", "next", replacement)
|
||||
assert cancelled.is_set()
|
||||
assert registry.get("github_copilot", "first") is None
|
||||
assert registry.get("github_copilot", "next") is None
|
||||
assert registry.has_pending_work
|
||||
finally:
|
||||
release.set()
|
||||
flow.wait_closed()
|
||||
assert not registry.has_pending_work
|
||||
registry.register("github_copilot", "next", replacement)
|
||||
registry.close()
|
||||
with pytest.raises(RuntimeError, match="closing"):
|
||||
registry.register("github_copilot", "after-close", _Flow())
|
||||
|
||||
|
||||
def test_oauth_registry_keeps_flow_that_starts_while_cancellation_is_pending():
|
||||
cancelling, allow_cancel, release_worker = (threading.Event() for _ in range(3))
|
||||
|
||||
class StartingFlow(_Flow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.thread = threading.Thread(target=lambda: release_worker.wait(3))
|
||||
|
||||
@property
|
||||
def has_pending_work(self):
|
||||
return self.thread.is_alive()
|
||||
|
||||
def cancel(self):
|
||||
cancelling.set()
|
||||
assert allow_cancel.wait(3)
|
||||
|
||||
def wait_closed(self):
|
||||
if self.thread.ident is not None:
|
||||
self.thread.join()
|
||||
|
||||
registry = WebUIOAuthFlowRegistry(max_flows=2)
|
||||
flow = StartingFlow()
|
||||
registry.register("github_copilot", "starting", flow)
|
||||
removal = threading.Thread(target=lambda: registry.remove("github_copilot", "starting", flow))
|
||||
removal.start()
|
||||
try:
|
||||
assert cancelling.wait(1)
|
||||
# Another request can register between register/start in the first login,
|
||||
# while its cancellation is waiting for the provider's commit lock.
|
||||
registry.register("xai_grok", "another", _Flow())
|
||||
flow.thread.start()
|
||||
allow_cancel.set()
|
||||
removal.join(timeout=1)
|
||||
assert not removal.is_alive()
|
||||
assert registry.has_pending_work
|
||||
finally:
|
||||
allow_cancel.set()
|
||||
release_worker.set()
|
||||
removal.join(timeout=2)
|
||||
flow.wait_closed()
|
||||
registry.close()
|
||||
Reference in new issue
Block a user