Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(desktop): stop the admin-rights warning on accounts where it is a false alarm (#1010)
Ruben Lütke2c73ad8d7dc6
diff --git a/dodaios/platform/deescalate.py b/dodaios/platform/deescalate.pyindex 6112636d3c..211636e6b8 100644--- a/dodaios/platform/deescalate.py+++ b/dodaios/platform/deescalate.py@@ -391,6 +391,7 @@ def maybe_relaunch_unelevated(env: dict[str, str] | None = None,creationflags: int = 0,_elevated=current_process_is_elevated,+ _shell_elevated=None,_spawn=spawn_unelevated,) -> DeescalationResult | None:"""Hand this boot over to an unelevated copy of ourselves, before it costs.@@ -424,6 +425,15 @@ def maybe_relaunch_unelevated(# relaunching on a guess would strand a user whose app is perfectly fine.if _elevated() is not True:return None+ # When the desktop shell is elevated too (built-in Administrator, UAC off),+ # every ordinary token on this account is elevated: a relaunch would come+ # straight back elevated, and nothing is isolated anyway.+ if _shell_elevated is None:+ from .input_isolation import windows_shell_is_elevated # noqa: PLC0415++ _shell_elevated = windows_shell_is_elevated+ if _shell_elevated() is True:+ return Nonechild_env = dict(os.environ if env is None else env)child_env[DEESCALATION_ATTEMPTED_ENV] = "1"diff --git a/dodaios/platform/input_isolation.py b/dodaios/platform/input_isolation.pyindex 5e63f8a85a..605246bca8 100644--- a/dodaios/platform/input_isolation.py+++ b/dodaios/platform/input_isolation.py@@ -276,6 +276,108 @@ def windows_foreground_window_is_elevated() -> bool | None:return None+def _windows_pid_is_elevated(pid: int) -> bool | None:+ """Is process ``pid`` running with an elevated token? ``None`` if unknown."""+ if os.name != "nt" or not pid:+ return None+ try:+ import ctypes # noqa: PLC0415 — lazy (HN-7)+ from ctypes import wintypes # noqa: PLC0415++ TOKEN_QUERY = 0x0008+ TokenElevation = 20+ PROCESS_QUERY_LIMITED_INFORMATION = 0x1000++ advapi32 = ctypes.WinDLL("advapi32", use_last_error=True)+ kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)+ # Declared on purpose: an undeclared 64-bit HANDLE is truncated to int.+ kernel32.OpenProcess.argtypes = [wintypes.DWORD, wintypes.BOOL, wintypes.DWORD]+ kernel32.OpenProcess.restype = wintypes.HANDLE+ kernel32.CloseHandle.argtypes = [wintypes.HANDLE]+ kernel32.CloseHandle.restype = wintypes.BOOL+ advapi32.OpenProcessToken.argtypes = [+ wintypes.HANDLE,+ wintypes.DWORD,+ ctypes.POINTER(wintypes.HANDLE),+ ]+ advapi32.OpenProcessToken.restype = wintypes.BOOL+ advapi32.GetTokenInformation.argtypes = [+ wintypes.HANDLE,+ ctypes.c_int,+ wintypes.LPVOID,+ wintypes.DWORD,+ ctypes.POINTER(wintypes.DWORD),+ ]+ advapi32.GetTokenInformation.restype = wintypes.BOOL++ process = kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, False, pid)+ if not process:+ return None+ try:+ token = wintypes.HANDLE()+ if not advapi32.OpenProcessToken(process, TOKEN_QUERY, ctypes.byref(token)):+ return None+ try:+ elevated = wintypes.DWORD()+ returned = wintypes.DWORD()+ if not advapi32.GetTokenInformation(+ token,+ TokenElevation,+ ctypes.cast(ctypes.byref(elevated), wintypes.LPVOID),+ ctypes.sizeof(elevated),+ ctypes.byref(returned),+ ):+ return None+ return bool(elevated.value)+ finally:+ kernel32.CloseHandle(token)+ finally:+ kernel32.CloseHandle(process)+ except Exception: # noqa: BLE001 — an unreadable token is "unknown", not fatal+ log.debug("Could not read the elevation of pid %s", pid, exc_info=True)+ return None+++def windows_shell_is_elevated() -> bool | None:+ """Does the desktop shell (Explorer) itself run with administrator rights?++ This decides whether our own elevation isolates anything. UIPI only blocks+ input from a LOWER integrity level. On the built-in Administrator account+ (default ``FilterAdministratorToken=0``) or with UAC switched off, Explorer+ runs elevated, so every app the user starts — dictation apps included — is+ elevated too and can type into our window just fine. Warning there is a+ false alarm, and "restart without admin rights" cannot help: the only+ ordinary token on that account is an elevated one (live report 2026-10-27:+ banner on every start, the restart button did nothing).++ ``None`` when unknown or not on Windows. Never raises.+ """+ if os.name != "nt":+ return None+ try:+ import ctypes # noqa: PLC0415 — lazy (HN-7)+ from ctypes import wintypes # noqa: PLC0415++ user32 = ctypes.WinDLL("user32", use_last_error=True)+ user32.GetShellWindow.argtypes = []+ user32.GetShellWindow.restype = wintypes.HWND+ user32.GetWindowThreadProcessId.argtypes = [+ wintypes.HWND,+ ctypes.POINTER(wintypes.DWORD),+ ]+ user32.GetWindowThreadProcessId.restype = wintypes.DWORD++ hwnd = user32.GetShellWindow()+ if not hwnd:+ return None+ pid = wintypes.DWORD()+ user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))+ return _windows_pid_is_elevated(int(pid.value))+ except Exception: # noqa: BLE001+ log.debug("Could not read the desktop shell's elevation", exc_info=True)+ return None++def macos_secure_input_enabled() -> bool | None:"""Is macOS Secure Input active right now?@@ -321,6 +423,7 @@ def describe_input_isolation(*,_platform=detect_platform,_elevated=windows_process_is_elevated,+ _shell_elevated=windows_shell_is_elevated,_euid=_euid,) -> InputIsolationReport:"""Report whether outside input software can reach this app's window.@@ -328,7 +431,9 @@ def describe_input_isolation(Fail-open by design: when the privilege state cannot be read we report``UNKNOWN`` and ``blocked=False``, because warning a user about a problemthey may not have — and offering a restart they do not need — is worse than- staying quiet. A real block is always a positive measurement.+ staying quiet. A real block is always a positive measurement: we run+ elevated AND the desktop shell does not. When the shell is elevated too,+ every app of this user shares our level and nothing is isolated."""platform = _platform()@@ -343,7 +448,7 @@ def describe_input_isolation(remedy="",can_restart_unelevated=False,)- if elevated:+ if elevated and _shell_elevated() is False:return InputIsolationReport(blocked=True,reason=InputIsolationReason.ELEVATED,diff --git a/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.test.tsx b/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.test.tsxindex 16cb010f23..77e370e7ea 100644--- a/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.test.tsx+++ b/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.test.tsx@@ -34,6 +34,7 @@ function blocked(overrides: Partial<InputIsolationReport> = {}): InputIsolationRafterEach(() => {cleanup();+ window.localStorage.clear();vi.clearAllMocks();vi.unstubAllGlobals();mockReport = null;@@ -59,7 +60,10 @@ describe("InputIsolationBanner", () => {expect(screen.getByTestId("input-isolation-banner")).toBeDefined();expect(screen.getByText("input_isolation.title")).toBeDefined();- expect(screen.getByText("input_isolation.impact")).toBeDefined();+ // The long explanation lives in a tooltip, not in the strip.+ expect(screen.getByTestId("input-isolation-banner").getAttribute("title")).toBe(+ "input_isolation.impact",+ );expect(screen.getByText("input_isolation.restart_now")).toBeDefined();});@@ -84,7 +88,9 @@ describe("InputIsolationBanner", () => {mockReport = blocked({ can_restart_unelevated: false });render(<InputIsolationBanner />);- expect(screen.getByText("input_isolation.manual_hint")).toBeDefined();+ expect(+ screen.getByTestId("input-isolation-banner").getAttribute("title"),+ ).toContain("input_isolation.manual_hint");expect(screen.queryByText("input_isolation.restart_now")).toBeNull();});@@ -136,4 +142,14 @@ describe("InputIsolationBanner", () => {fireEvent.click(screen.getByLabelText("input_isolation.dismiss"));expect(screen.queryByTestId("input-isolation-banner")).toBeNull();});++ it("stays hidden on the next start once the user dismissed it", () => {+ mockReport = blocked();+ render(<InputIsolationBanner />);+ fireEvent.click(screen.getByLabelText("input_isolation.dismiss"));+ cleanup();++ render(<InputIsolationBanner />);+ expect(screen.queryByTestId("input-isolation-banner")).toBeNull();+ });});diff --git a/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.tsx b/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.tsxindex e0ab4dc688..8e102a484b 100644--- a/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.tsx+++ b/dodaios/ui/web/frontend/src/components/layout/InputIsolationBanner.tsx@@ -1,6 +1,5 @@import { useState } from "react";import { KeyboardOff, Loader2, X } from "lucide-react";-import { Button } from "@/components/ui/button";import { useT } from "@/i18n";import { useEventStore } from "@/store/events";import { useInputIsolation } from "@/hooks/useInputIsolation";@@ -19,13 +18,36 @@ import { useInputIsolation } from "@/hooks/useInputIsolation";** Renders nothing whenever the window is reachable, which is the normal case on* every platform — including when the privilege state could not be read at all- * (we never nag on a guess).+ * (we never nag on a guess), and on accounts whose whole desktop runs elevated,+ * where nothing is isolated (the backend checks the shell's level too).+ *+ * Kept quiet on purpose: one small line, the long explanation in a tooltip, and+ * a dismissal that is remembered, so a user who closed it never sees it again.*/++const DISMISS_KEY = "dodaios.inputIsolation.dismissed";++function readDismissed(): boolean {+ try {+ return window.localStorage.getItem(DISMISS_KEY) === "1";+ } catch {+ return false;+ }+}++function rememberDismissed() {+ try {+ window.localStorage.setItem(DISMISS_KEY, "1");+ } catch {+ // Storage blocked: the notice just stays hidden for this session.+ }+}+export function InputIsolationBanner() {const t = useT();const pushToast = useEventStore((state) => state.pushToast);const { report } = useInputIsolation();- const [dismissed, setDismissed] = useState(false);+ const [dismissed, setDismissed] = useState(readDismissed);const [restarting, setRestarting] = useState(false);if (!report?.blocked || dismissed) return null;@@ -54,52 +76,43 @@ export function InputIsolationBanner() {setRestarting(false);}+ const details = report.can_restart_unelevated+ ? t("input_isolation.impact")+ : `${t("input_isolation.impact")} ${t("input_isolation.manual_hint")}`;+return (<divdata-testid="input-isolation-banner"data-reason={report.reason}- role="alert"- // A full-width strip stays on the page's own ground: the state is said- // by the glyph and the hairline, not by washing the top of the window in- // an alpha of the ink colour.- className="border-b border-warning"+ role="status"+ title={details}+ className="flex items-center gap-2 px-4 py-1 text-meta text-muted-foreground">- <div className="flex items-start gap-3 px-4 py-2.5">- <KeyboardOff className="mt-0.5 h-5 w-5 shrink-0 text-warning" aria-hidden />- <div className="min-w-0 flex-1">- <p className="text-body font-semibold text-foreground-strong">- {t("input_isolation.title")}- </p>- <p className="mt-0.5 text-meta text-muted-foreground">- {t("input_isolation.impact")}- </p>- {!report.can_restart_unelevated && (- <p className="mt-1 text-meta text-muted-foreground">- {t("input_isolation.manual_hint")}- </p>- )}- </div>- {report.can_restart_unelevated && (- <Button- size="sm"- disabled={restarting}- onClick={() => void restartUnelevated()}- >- {restarting && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}- {t(restarting ? "input_isolation.restarting" : "input_isolation.restart_now")}- </Button>- )}- <Button- size="icon"- variant="ghost"- className="h-7 w-7 shrink-0"- aria-label={t("input_isolation.dismiss")}- title={t("input_isolation.dismiss")}- onClick={() => setDismissed(true)}+ <KeyboardOff className="h-3.5 w-3.5 shrink-0 text-warning" aria-hidden />+ <span className="min-w-0 flex-1 truncate">{t("input_isolation.title")}</span>+ {report.can_restart_unelevated && (+ <button+ type="button"+ disabled={restarting}+ onClick={() => void restartUnelevated()}+ className="inline-flex shrink-0 items-center gap-1 text-foreground underline-offset-2 hover:underline disabled:opacity-60">- <X className="h-3.5 w-3.5" aria-hidden />- </Button>- </div>+ {restarting && <Loader2 className="h-3 w-3 animate-spin" aria-hidden />}+ {t(restarting ? "input_isolation.restarting" : "input_isolation.restart_now")}+ </button>+ )}+ <button+ type="button"+ className="shrink-0 rounded p-0.5 hover:text-foreground"+ aria-label={t("input_isolation.dismiss")}+ title={t("input_isolation.dismiss")}+ onClick={() => {+ rememberDismissed();+ setDismissed(true);+ }}+ >+ <X className="h-3 w-3" aria-hidden />+ </button></div>);}diff --git a/dodaios/ui/web/frontend/src/i18n/locales/de.json b/dodaios/ui/web/frontend/src/i18n/locales/de.jsonindex f365507669..876a07eb37 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/de.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/de.json@@ -202,10 +202,10 @@"save_changes": "Änderungen speichern"},"input_isolation": {- "title": "Diktier- und Tipphilfen erreichen dieses Fenster nicht",+ "title": "Diktier- und Tipp-Apps können nicht in dieses Fenster schreiben, solange es als Administrator läuft.","impact": "Diese App läuft mit Administratorrechten, deshalb lässt Windows andere Programme nicht in ihr Fenster schreiben. Diktier-Apps, Textbausteine, Zwischenablage-Tools und das automatische Ausfüllen von Passwort-Managern scheinen hier nichts zu tun, während sie in jeder anderen App weiterhin funktionieren.","manual_hint": "Die App kann die Administratorrechte auf diesem Windows-Konto nicht selbst ablegen. Schließe sie und starte sie normal neu — ohne „Als Administrator ausführen“.",- "restart_now": "Ohne Administratorrechte neu starten",+ "restart_now": "Normal neu starten","restarting": "Wird neu gestartet…","restart_failed": "Die App konnte nicht ohne Administratorrechte neu gestartet werden.","dismiss": "Hinweis ausblenden"diff --git a/dodaios/ui/web/frontend/src/i18n/locales/en.json b/dodaios/ui/web/frontend/src/i18n/locales/en.jsonindex 9f57b4e976..12262d385c 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/en.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/en.json@@ -202,10 +202,10 @@"save_changes": "Save changes"},"input_isolation": {- "title": "Dictation and typing tools can't reach this window",+ "title": "Dictation and typing apps can't type into this window while it runs as administrator.","impact": "This app is running with administrator rights, so Windows blocks other programs from typing into it. Dictation apps, text expanders, clipboard tools, and password-manager auto-type will seem to do nothing here, while still working in every other app.","manual_hint": "This app can't drop the administrator rights by itself on this Windows account. Close it and start it again normally — without “Run as administrator”.",- "restart_now": "Restart without admin rights",+ "restart_now": "Restart normally","restarting": "Restarting…","restart_failed": "The app could not restart without administrator rights.","dismiss": "Hide this notice"diff --git a/dodaios/ui/web/frontend/src/i18n/locales/es.json b/dodaios/ui/web/frontend/src/i18n/locales/es.jsonindex 69b70affb1..50c0ecfd03 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/es.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/es.json@@ -202,10 +202,10 @@"save_changes": "Guardar cambios"},"input_isolation": {- "title": "Las herramientas de dictado y escritura no alcanzan esta ventana",+ "title": "Las apps de dictado y escritura no pueden escribir en esta ventana mientras se ejecuta como administrador.","impact": "Esta aplicación se está ejecutando con permisos de administrador, por lo que Windows impide que otros programas escriban en ella. Las apps de dictado, los expansores de texto, los gestores de portapapeles y el autocompletado de los gestores de contraseñas parecerán no hacer nada aquí, aunque sigan funcionando en el resto de aplicaciones.","manual_hint": "La aplicación no puede renunciar por sí misma a los permisos de administrador en esta cuenta de Windows. Ciérrala y vuelve a abrirla con normalidad, sin «Ejecutar como administrador».",- "restart_now": "Reiniciar sin permisos de administrador",+ "restart_now": "Reiniciar normalmente","restarting": "Reiniciando…","restart_failed": "No se pudo reiniciar la aplicación sin permisos de administrador.","dismiss": "Ocultar este aviso"diff --git a/dodaios/ui/web/frontend/src/i18n/locales/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/pt.jsonindex bf5727b8a5..eb03d8fdb1 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/pt.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/pt.json@@ -202,10 +202,10 @@"save_changes": "Guardar alterações"},"input_isolation": {- "title": "As ferramentas de ditado e escrita não chegam a esta janela",+ "title": "As apps de ditado e escrita não conseguem escrever nesta janela enquanto corre como administrador.","impact": "Esta aplicação está a correr com direitos de administrador, por isso o Windows impede outros programas de escrever nela. Apps de ditado, expansores de texto, ferramentas de área de transferência e o preenchimento automático de gestores de palavras-passe parecerão não fazer nada aqui, embora continuem a funcionar em todas as outras aplicações.","manual_hint": "Esta aplicação não consegue largar os direitos de administrador sozinha nesta conta do Windows. Fecha-a e volta a iniciá-la normalmente — sem “Executar como administrador”.",- "restart_now": "Reiniciar sem direitos de admin",+ "restart_now": "Reiniciar normalmente","restarting": "A reiniciar…","restart_failed": "Não foi possível reiniciar a aplicação sem direitos de administrador.","dismiss": "Ocultar este aviso"diff --git a/dodaios/ui/web/frontend/src/i18n/locales/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/zh.jsonindex f516a68c2c..96ce8c5385 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/zh.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/zh.json@@ -202,10 +202,10 @@"save_changes": "保存更改"},"input_isolation": {- "title": "听写和输入工具无法访问此窗口",+ "title": "此窗口以管理员身份运行时,听写和输入应用无法在其中输入。","impact": "此应用正以管理员权限运行,因此 Windows 会阻止其他程序向它输入内容。听写应用、文本扩展工具、剪贴板工具和密码管理器的自动输入在这里看起来都没有反应,但在其他应用中仍然正常。","manual_hint": "在这个 Windows 账号上,此应用无法自行放弃管理员权限。请关闭它,然后以普通方式重新启动,不要使用“以管理员身份运行”。",- "restart_now": "以非管理员权限重启",+ "restart_now": "正常重启","restarting": "正在重启…","restart_failed": "应用无法以非管理员权限重启。","dismiss": "隐藏此提示"diff --git a/tests/unit/platform/test_deescalate.py b/tests/unit/platform/test_deescalate.pyindex 00839c343e..84850b1f91 100644--- a/tests/unit/platform/test_deescalate.py+++ b/tests/unit/platform/test_deescalate.py@@ -140,6 +140,10 @@ def _clean_deescalation_env(monkeypatch):"""Neither guard variable may leak in from the host running the tests."""monkeypatch.delenv(DEESCALATION_ATTEMPTED_ENV, raising=False)monkeypatch.delenv(KEEP_ELEVATION_ENV, raising=False)+ # Nor the host's desktop shell: CI runners often run Explorer elevated.+ monkeypatch.setattr(+ "dodaios.platform.input_isolation.windows_shell_is_elevated", lambda: False+ )class TestBootTimeDeescalation:@@ -239,6 +243,24 @@ class TestBootTimeDeescalation:)assert calls == []+ def test_an_elevated_shell_skips_the_pointless_relaunch(self, monkeypatch):+ """With Explorer elevated every ordinary token is elevated: the child+ would come back elevated, after paying for a whole extra boot."""+ monkeypatch.setattr("sys.platform", "win32")+ calls: list = []++ assert (+ maybe_relaunch_unelevated(+ ["py"],+ cwd=".",+ _elevated=lambda: True,+ _shell_elevated=lambda: True,+ _spawn=_spawner(calls),+ )+ is None+ )+ assert calls == []+def test_a_refused_handover_is_reported_not_swallowed(self, monkeypatch):"""The caller must be able to tell "exit now" from "boot elevated andwarn", so a failure has to come back as a result, never as ``None``."""diff --git a/tests/unit/platform/test_input_isolation.py b/tests/unit/platform/test_input_isolation.pyindex 680e627253..1c9e052c6a 100644--- a/tests/unit/platform/test_input_isolation.py+++ b/tests/unit/platform/test_input_isolation.py@@ -25,10 +25,11 @@ from dodaios.platform.input_isolation import ()-def _report(platform: str, elevated: bool | None):+def _report(platform: str, elevated: bool | None, shell_elevated: bool | None = False):return describe_input_isolation(_platform=lambda: platform,_elevated=lambda: elevated,+ _shell_elevated=lambda: shell_elevated,_euid=lambda: 1000,)@@ -55,6 +56,21 @@ class TestWindows:assert report.can_restart_unelevated is False+class TestElevatedSession:+ """Built-in Administrator account or UAC off: Explorer itself is elevated,+ so every app the user starts shares our level. Live report 2026-10-27:+ the warning showed on every start and its restart button changed nothing."""++ def test_elevated_shell_is_not_a_block(self):+ report = _report("win32", True, shell_elevated=True)+ assert report.blocked is False+ assert report.can_restart_unelevated is False++ def test_unknown_shell_state_never_nags(self):+ report = _report("win32", True, shell_elevated=None)+ assert report.blocked is False++class TestPosix:@pytest.mark.parametrize("platform", ["darwin", "linux"])def test_ordinary_user_session_is_reachable(self, platform):