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(voice): make ChatGPT-subscription voice work off Windows
rubenluetke10-beepc895a0d16006
diff --git a/jarvis/codex_app_server.py b/jarvis/codex_app_server.pyindex 29fa2fe802..d2685b1e85 100644--- a/jarvis/codex_app_server.py+++ b/jarvis/codex_app_server.py@@ -1133,6 +1133,39 @@ _HEADLESS_LOGIN_REASON: Final = ("Interactive subscription-voice login is unavailable on headless Linux. ""Run Jarvis on a desktop to connect this dedicated profile.")+_NO_LOGIN_TERMINAL_REASON: Final = (+ "Interactive subscription-voice login needs a terminal emulator this "+ "desktop does not provide. Install one (for example gnome-terminal, "+ "konsole, xfce4-terminal, kitty or alacritty) and connect again."+)+++def _headless_linux() -> bool:+ """A Linux host with no graphical session at all."""+ return (+ sys.platform.startswith("linux")+ and not os.environ.get("DISPLAY")+ and not os.environ.get("WAYLAND_DISPLAY")+ )+++def _linux_login_terminal_missing() -> bool:+ """True on a graphical Linux host with no terminal able to host the login.++ Separate from the headless check: a screen exists, so the old probe said+ "login_required" and the card offered a Connect that could only ever fail.+ """+ if not sys.platform.startswith("linux") or _headless_linux():+ return False+ try:+ from jarvis.codex_auth import ( # noqa: PLC0415+ linux_login_terminal_available,+ )++ return not linux_login_terminal_available()+ except Exception: # noqa: BLE001 - an unknown probe must not block a login+ log.debug("Linux login-terminal probe failed", exc_info=True)+ return Falsedef _login_required_reason_code() -> CodexSubscriptionReasonCode:@@ -1141,13 +1174,11 @@ def _login_required_reason_code() -> CodexSubscriptionReasonCode:On a headless Linux host the interactive browser login is impossible, soinviting it would only produce an error toast after the click — thepre-click truth there is ``lifecycle_unavailable`` (visible degradation,- CLAUDE.md §3). An EXISTING login still reports ready on such hosts.+ CLAUDE.md §3). The same holds for a graphical Linux desktop that ships no+ terminal able to host the login for its full lifetime. An EXISTING login+ still reports ready on such hosts."""- if (- sys.platform.startswith("linux")- and not os.environ.get("DISPLAY")- and not os.environ.get("WAYLAND_DISPLAY")- ):+ if _headless_linux() or _linux_login_terminal_missing():return "lifecycle_unavailable"return "login_required"@@ -1161,7 +1192,11 @@ def _login_required_state(reason: str) -> tuple[str, CodexSubscriptionReasonCode"""code = _login_required_reason_code()if code == "lifecycle_unavailable":- reason = _HEADLESS_LOGIN_REASON+ reason = (+ _HEADLESS_LOGIN_REASON+ if _headless_linux()+ else _NO_LOGIN_TERMINAL_REASON+ )return reason, code@@ -3811,15 +3846,12 @@ def start_codex_subscription_login(from jarvis.codex_auth import CodexAuthService- if (- sys.platform.startswith("linux")- and not os.environ.get("DISPLAY")- and not os.environ.get("WAYLAND_DISPLAY")- ):- raise CodexSubscriptionUnavailable(- "Interactive subscription-voice login is unavailable on headless Linux. "- "Run Jarvis on a desktop to connect this dedicated profile."- )+ if _headless_linux():+ raise CodexSubscriptionUnavailable(_HEADLESS_LOGIN_REASON)+ if _linux_login_terminal_missing():+ # Same pre-click truth the card shows, so the click and the card can+ # never disagree about why this desktop cannot host the login.+ raise CodexSubscriptionUnavailable(_NO_LOGIN_TERMINAL_REASON)with _subscription_login_lock:_await_status_probe_completion_locked()if _subscription_profile_mutating or _subscription_login_in_flight:diff --git a/jarvis/codex_auth.py b/jarvis/codex_auth.pyindex f78c15cf7e..743a5a12cc 100644--- a/jarvis/codex_auth.py+++ b/jarvis/codex_auth.py@@ -65,6 +65,31 @@ _VERSION_CACHE: dict[str, str | None] = {}# dynamic-loader, keyring, or agent-session state. Keep this list deliberately# small: these are OS process essentials, not a denylist that has to predict the# next credential variable name.+#: Graphical-session handles a login child needs to OPEN THE BROWSER itself.+#:+#: Windows (ShellExecute) and macOS (``open``) need nothing here, so this set is+#: inert on those hosts by construction — the names simply do not exist. On+#: Linux their absence is what forced the user to copy the device-code URL out+#: of the terminal by hand while the other two OSes opened the page for them.+#: These are session handles, not credentials: no provider key, token, proxy or+#: keyring name is admitted by adding them.+#:+#: Deliberately partial: ``_subprocess_environment`` still strips+#: ``DBUS_SESSION_BUS_ADDRESS`` and ``XDG_RUNTIME_DIR`` whenever the file+#: credential store is forced, because those two are exactly how a Secret+#: Service would be reached — the file-store guarantee outranks convenience.+#: X11 (and XWayland, which is nearly every Wayland desktop) opens the page+#: from ``DISPLAY`` + ``XAUTHORITY`` alone; a pure-Wayland session without+#: XWayland still falls back to the printed device-code URL.+_GRAPHICAL_SESSION_ENV_NAMES: frozenset[str] = frozenset(+ {+ "DBUS_SESSION_BUS_ADDRESS",+ "DISPLAY",+ "WAYLAND_DISPLAY",+ "XAUTHORITY",+ "XDG_RUNTIME_DIR",+ }+)_ISOLATED_CODEX_ENV_ALLOWLIST: frozenset[str] = frozenset({"COMSPEC",@@ -84,21 +109,100 @@ _ISOLATED_CODEX_ENV_ALLOWLIST: frozenset[str] = frozenset("USERPROFILE","WINDIR",}-)+) | _GRAPHICAL_SESSION_ENV_NAMES_DESKTOP_LAUNCHER_ENV_ALLOWLIST: frozenset[str] = frozenset({- "DBUS_SESSION_BUS_ADDRESS","DESKTOP_SESSION",- "DISPLAY",- "WAYLAND_DISPLAY",- "XAUTHORITY","XDG_CURRENT_DESKTOP",- "XDG_RUNTIME_DIR","XDG_SESSION_TYPE",}+) | _GRAPHICAL_SESSION_ENV_NAMES++#: Linux terminals that can host a Codex login for its FULL lifetime.+#:+#: The login guardian owns the profile lock until the codex child exits, so a+#: launcher that returns the moment it has handed the work to a terminal SERVER+#: would release that lock while ``auth.json`` is still being written. Every+#: entry therefore uses that terminal's documented foreground / no-fork /+#: no-server form. Matching is on the RESOLVED binary name, so Debian's+#: ``x-terminal-emulator`` alternative resolves to a real entry here too.+#:+#: The list used to hold three names. A desktop without GNOME, KDE or a literal+#: ``xterm`` — XFCE, MATE, Cinnamon, or anyone on kitty/alacritty/foot/wezterm —+#: could therefore not connect subscription voice AT ALL, while the card happily+#: invited the click. ``jarvis/core/interactive_terminal.py`` already knew most+#: of these; the two lists disagreeing was the whole defect.+_LINUX_LOGIN_TERMINALS: tuple[tuple[str, tuple[str, ...]], ...] = (+ ("gnome-terminal", ("--wait", "--")),+ ("konsole", ("--nofork", "-e")),+ ("xfce4-terminal", ("--disable-server", "-x")),+ ("mate-terminal", ("--disable-factory", "-x")),+ ("tilix", ("--new-process", "-e")),+ ("terminator", ("--no-dbus", "-x")),+ ("kitty", ()),+ ("alacritty", ("-e",)),+ ("wezterm", ("start", "--")),+ ("foot", ()),+ ("urxvt", ("-e",)),+ ("rxvt", ("-e",)),+ ("xterm", ("-e",)),+ ("st", ("-e",)),)+def _resolve_linux_login_terminal() -> tuple[str, tuple[str, ...]]:+ """Pick a Linux terminal able to host the login until Codex exits.++ Returns the resolved executable and the flags that put it in the+ foreground. Raises with an actionable English message when this desktop+ ships nothing usable — the caller turns that into the card's honest reason+ instead of an unexplained failure.+ """+ supported = ", ".join(name for name, _flags in _LINUX_LOGIN_TERMINALS)+ candidates = [+ path+ for path in (shutil.which(name) for name, _flags in _LINUX_LOGIN_TERMINALS)+ if path+ ]+ generic = shutil.which("x-terminal-emulator")+ if generic:+ candidates.append(generic)+ for candidate in candidates:+ try:+ resolved = str(Path(candidate).resolve())+ except OSError: # A dangling alternative symlink is simply not usable.+ continue+ name = Path(resolved).name.lower()+ for prefix, flags in _LINUX_LOGIN_TERMINALS:+ if name.startswith(prefix):+ return resolved, flags+ if candidates:+ raise RuntimeError(+ "The available desktop terminal cannot host a Codex login for its "+ f"full lifetime. Install one of: {supported}."+ )+ raise RuntimeError(+ "No supported desktop terminal is available for Codex login. "+ f"Install one of: {supported}."+ )+++def linux_login_terminal_available() -> bool:+ """Whether a visible Linux login could actually be launched here.++ A pre-click capability probe: the Connect action must not be offered on a+ desktop where the launch is guaranteed to fail (the error-toast+ anti-pattern the OS-parity register exists to prevent).+ """+ if sys.platform == "win32" or sys.platform == "darwin":+ return True+ try:+ _resolve_linux_login_terminal()+ except RuntimeError:+ return False+ return True++def clear_version_cache() -> None:"""Drop all cached ``codex --version`` results.@@ -765,53 +869,8 @@ class CodexAuthService:)command = ["/usr/bin/osascript", "-e", script]else:- terminal = next(- (- candidate- for candidate in (- shutil.which("gnome-terminal"),- shutil.which("konsole"),- shutil.which("xterm"),- )- if candidate- ),- None,- )- if terminal is None:- terminal = shutil.which("x-terminal-emulator")- if terminal is None:- raise RuntimeError(- "No supported desktop terminal is available for Codex login."- )- # Resolve Debian's x-terminal-emulator alternative before- # choosing flags. Generic terminal launchers may return as- # soon as they hand work to a terminal server, which would- # release the profile login guard while Codex still writes- # auth.json. Only backends with a documented wait/no-fork- # form are accepted.- resolved_terminal = str(Path(terminal).resolve())- terminal_name = Path(resolved_terminal).name.lower()- if terminal_name.startswith("gnome-terminal"):- command = [- resolved_terminal,- "--wait",- "--",- *terminal_command,- ]- elif terminal_name.startswith("konsole"):- command = [- resolved_terminal,- "--nofork",- "-e",- *terminal_command,- ]- elif terminal_name == "xterm":- command = [resolved_terminal, "-e", *terminal_command]- else:- raise RuntimeError(- "The configured desktop terminal cannot provide a bounded "- "Codex login lifetime."- )+ resolved_terminal, terminal_flags = _resolve_linux_login_terminal()+ command = [resolved_terminal, *terminal_flags, *terminal_command]kwargs = {"env": environment,"start_new_session": True,@@ -831,18 +890,34 @@ class CodexAuthService:if environment is not None and "env" not in kwargs:kwargs["env"] = environmentprocess_tree: Any | None = None- if guard_paths is not None and sys.platform == "win32":+ if guard_paths is not None:+ # Containment is a capability, not a Windows feature. On POSIX the+ # guardian holds the profile lock, so a Jarvis crash used to leave+ # terminal -> guardian -> `codex login` alive with the lock still+ # taken, and every later connect attempt reported a permanent+ # "busy". `make_process_tree` returns a real process-group reaper+ # there and an honest no-op where neither exists.from jarvis.core.process_tree import make_process_tree # noqa: PLC0415process_tree = make_process_tree("codex-subscription-login")if not bool(getattr(process_tree, "supports_containment", False)):process_tree.close()- raise RuntimeError(- "Windows process-tree containment is unavailable for Codex login."+ if sys.platform == "win32":+ raise RuntimeError(+ "Windows process-tree containment is unavailable for Codex login."+ )+ # Elsewhere a missing reaper costs cleanup, not correctness:+ # the lock is also released by the guardian's own handshake.+ log.warning(+ "Codex subscription login runs without process-tree "+ "containment on this host; a crash may leave the login "+ "terminal behind."+ )+ process_tree = None+ elif sys.platform == "win32":+ kwargs["creationflags"] = int(kwargs.get("creationflags", 0)) | (+ _CREATE_BREAKAWAY_FROM_JOB)- kwargs["creationflags"] = int(kwargs.get("creationflags", 0)) | (- _CREATE_BREAKAWAY_FROM_JOB- )try:try:process = subprocess.Popen( # noqa: S603 — fixed argv, shell=False@@ -850,7 +925,10 @@ class CodexAuthService:**kwargs,)except PermissionError:- if process_tree is None:+ # Only the Windows breakaway flag is retryable; on POSIX a+ # PermissionError is a real launch failure, not a containment+ # policy the retry could relax.+ if process_tree is None or sys.platform != "win32":raisekwargs["creationflags"] = int(kwargs.get("creationflags", 0)) & (~_CREATE_BREAKAWAY_FROM_JOB@@ -874,7 +952,7 @@ class CodexAuthService:except OSError:passraise RuntimeError(- "Windows process-tree containment could not be established for Codex login."+ "Process-tree containment could not be established for Codex login.") from excif guard_paths is None:return process@@ -901,6 +979,15 @@ class CodexAuthService:release,process_tree,)+ except RuntimeError as exc:+ if process_tree is not None:+ process_tree.close()+ else:+ try:+ process.terminate()+ except OSError:+ pass+ raise self._explain_login_launch_failure(exc, process) from excexcept BaseException:if process_tree is not None:process_tree.close()@@ -911,6 +998,28 @@ class CodexAuthService:passraise+ def _explain_login_launch_failure(+ self, exc: RuntimeError, process: subprocess.Popen[bytes]+ ) -> RuntimeError:+ """Name the real cause when a visible login never came up.++ On macOS the login rides in Terminal.app via ``osascript``. A denied+ Automation (TCC) grant makes osascript exit non-zero immediately, which+ reaches the user as "the guardian exited before lock handoff" — true,+ useless, and pointing at the wrong component. Every other host keeps+ the original message.+ """+ if sys.platform != "darwin" or not self._visible_login:+ return exc+ if process.poll() in (None, 0):+ return exc+ return RuntimeError(+ "The ChatGPT login window could not be opened. macOS is blocking "+ "Jarvis from controlling Terminal: allow it under System Settings "+ "> Privacy & Security > Automation, then connect again. "+ f"({exc})"+ )+def login_status(self) -> tuple[bool, str]:"""Return the CLI's PII-free login mode for this exact profile.diff --git a/jarvis/codex_login_guard.py b/jarvis/codex_login_guard.pyindex 10163c8a8d..093a7a83ee 100644--- a/jarvis/codex_login_guard.py+++ b/jarvis/codex_login_guard.py@@ -37,6 +37,11 @@ _ALLOWED_ENVIRONMENT_NAMES = frozenset("CODEX_HOME","CODEX_INTERNAL_APP_SERVER_REMOTE_CONTROL_DISABLED","COMSPEC",+ # Graphical-session handles, so the login child can open the OAuth page+ # itself on Linux exactly as it already does on Windows and macOS.+ # Session handles only — never a credential, proxy or keyring name.+ "DBUS_SESSION_BUS_ADDRESS",+ "DISPLAY","HOME","LANG","LOCALAPPDATA",@@ -53,7 +58,10 @@ _ALLOWED_ENVIRONMENT_NAMES = frozenset("TMP","TMPDIR","USERPROFILE",+ "WAYLAND_DISPLAY","WINDIR",+ "XAUTHORITY",+ "XDG_RUNTIME_DIR",})diff --git a/jarvis/plugins/brain/codex.py b/jarvis/plugins/brain/codex.pyindex ad72ff13c3..fa80a214a5 100644--- a/jarvis/plugins/brain/codex.py+++ b/jarvis/plugins/brain/codex.py@@ -60,7 +60,24 @@ _CLI_MODEL_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$")def _resolve_codex_binary() -> str | None:- """On-PATH ``codex`` binary (Windows shim variants included), or None."""+ """On-PATH ``codex`` binary (Windows shim variants included), or None.++ Delegates to the same resolver the Providers card uses. Doing its own+ ``shutil.which`` meant the card could report the subscription as connected+ while every action failed with "Codex CLI not found": a GUI-launched app on+ macOS (and a Windows app started from Explorer) inherits a login PATH that+ never saw the user's shell profile, and only ``CodexAuthService`` repairs+ that via ``ensure_cli_paths()``. Two resolvers, two answers, one confusing+ bug — so there is now one.+ """+ try:+ from jarvis.codex_auth import CodexAuthService # noqa: PLC0415++ resolved = CodexAuthService()._resolve_binary()+ if resolved:+ return resolved+ except Exception: # noqa: BLE001 — fall back to the plain PATH probe+ log.debug("Shared Codex binary resolution failed", exc_info=True)for name in ("codex", "codex.cmd", "codex.exe"):path = shutil.which(name)if path:@@ -68,6 +85,50 @@ def _resolve_codex_binary() -> str | None:return None+async def _terminate_posix_process_group(pid: int, proc: Any) -> None:+ """Reap a POSIX process group: ``SIGTERM``, a short grace, then ``SIGKILL``.++ Best-effort by nature — a tree that already exited is the good outcome, and+ a group we may not signal is not worth failing a teardown over.+ """+ import signal # noqa: PLC0415 — POSIX-only, kept off the import path++ killpg = getattr(os, "killpg", None)+ getpgid = getattr(os, "getpgid", None)+ if not callable(killpg):+ return+ try:+ pgid = getpgid(pid) if callable(getpgid) else pid+ except (ProcessLookupError, OSError):+ # Silence is right: the child is already gone, or has no readable+ # group. It was started with `start_new_session`, so its pid IS the+ # group in every case that still matters — falling back is exact.+ pgid = pid++ def _signal(sig: int) -> bool:+ try:+ killpg(pgid, sig)+ except (ProcessLookupError, PermissionError, OSError):+ # Silence is right: "already exited" is the outcome we wanted, and+ # a group that is not ours to signal cannot be reaped by retrying.+ # The bool tells the caller not to bother escalating.+ return False+ return True++ if not _signal(signal.SIGTERM):+ return+ try:+ await asyncio.wait_for(proc.wait(), timeout=2.0)+ return+ except Exception as exc: # noqa: BLE001 — SIGTERM ignored, escalate+ log.debug(+ "Codex CLI process group %s survived SIGTERM (%s); escalating",+ pgid,+ type(exc).__name__,+ )+ _signal(getattr(signal, "SIGKILL", signal.SIGTERM))++def _codex_oauth_connected() -> bool:"""True when ``codex login`` has stored a ChatGPT (OAuth) subscription token.@@ -279,6 +340,14 @@ class CodexBrain:)t0 = time.monotonic()+ # POSIX: give the CLI its own process group so a timeout can reap the+ # WHOLE tree. The npm launcher execs a real `codex` child; killing only+ # the launcher left that child running, so every capped or cancelled+ # subscription turn leaked a process on macOS and Linux while Windows+ # was already clean via `taskkill /T`. Windows rejects the kwarg.+ session_kwargs: dict[str, Any] = (+ {} if sys.platform == "win32" else {"start_new_session": True}+ )try:proc = await asyncio.create_subprocess_exec(*cmd,@@ -288,6 +357,7 @@ class CodexBrain:stdout=asyncio.subprocess.PIPE,stderr=asyncio.subprocess.PIPE,creationflags=creationflags,+ **session_kwargs,)except (FileNotFoundError, OSError) as exc:with suppress(OSError):@@ -325,6 +395,11 @@ class CodexBrain:creationflags=creationflags,)await asyncio.wait_for(killer.wait(), timeout=3.0)+ elif sys.platform != "win32" and isinstance(pid, int) and pid > 0:+ # The POSIX sibling of `taskkill /T`: the CLI leads its own+ # group (start_new_session above), so one signal reaps the+ # launcher AND the real codex child it exec'd.+ await _terminate_posix_process_group(pid, proc)with suppress(OSError):proc.kill()with suppress(Exception): # noqa: BLE001diff --git a/tests/unit/test_codex_auth.py b/tests/unit/test_codex_auth.pyindex 94e78ce181..7580256bc0 100644--- a/tests/unit/test_codex_auth.py+++ b/tests/unit/test_codex_auth.py@@ -766,3 +766,77 @@ def test_logout_returns_false_when_binary_missing(monkeypatch: pytest.MonkeyPatcok, err = svc.logout_blocking()assert ok is Falseassert err+++ ("available", "expected_flags"),+ [+ ("gnome-terminal", ["--wait", "--"]),+ ("konsole", ["--nofork", "-e"]),+ ("xfce4-terminal", ["--disable-server", "-x"]),+ ("mate-terminal", ["--disable-factory", "-x"]),+ ("tilix", ["--new-process", "-e"]),+ ("terminator", ["--no-dbus", "-x"]),+ ("kitty", []),+ ("alacritty", ["-e"]),+ ("wezterm", ["start", "--"]),+ ("foot", []),+ ("xterm", ["-e"]),+ ],+)+def test_linux_login_accepts_every_supported_terminal(+ monkeypatch: pytest.MonkeyPatch,+ available: str,+ expected_flags: list[str],+) -> None:+ """A desktop without GNOME/KDE/xterm could not connect at all.++ The old list held exactly three names, so XFCE, MATE, Cinnamon and anyone+ on kitty/alacritty/foot/wezterm hit a hard "no supported desktop terminal"+ while the Providers card still offered the Connect button.+ """+ import jarvis.codex_auth as codex_mod++ monkeypatch.setattr(codex_mod.sys, "platform", "linux")+ monkeypatch.setattr(+ codex_mod.shutil,+ "which",+ lambda name: f"/usr/bin/{available}" if name == available else None,+ )++ resolved, flags = codex_mod._resolve_linux_login_terminal()++ assert Path(resolved).name == available+ assert list(flags) == expected_flags+ assert codex_mod.linux_login_terminal_available() is True+++def test_linux_login_without_any_terminal_is_an_actionable_refusal(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """No usable terminal must be a named capability gap, not a mystery."""+ import jarvis.codex_auth as codex_mod++ monkeypatch.setattr(codex_mod.sys, "platform", "linux")+ monkeypatch.setattr(codex_mod.shutil, "which", lambda _name: None)++ with pytest.raises(RuntimeError, match="Install one of"):+ codex_mod._resolve_linux_login_terminal()+ assert codex_mod.linux_login_terminal_available() is False+++def test_graphical_linux_without_a_terminal_does_not_invite_a_login(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Pre-click truth: never offer a Connect that is guaranteed to fail."""+ import jarvis.codex_app_server as transport+ import jarvis.codex_auth as codex_mod++ monkeypatch.setattr(transport.sys, "platform", "linux")+ monkeypatch.setenv("DISPLAY", ":0")+ monkeypatch.setattr(codex_mod.shutil, "which", lambda _name: None)++ reason, code = transport._login_required_state("please log in")++ assert code == "lifecycle_unavailable"+ assert "terminal emulator" in reasondiff --git a/tests/unit/test_codex_login_guard.py b/tests/unit/test_codex_login_guard.pyindex a305e6cf4e..5b98f9898e 100644--- a/tests/unit/test_codex_login_guard.py+++ b/tests/unit/test_codex_login_guard.py@@ -180,15 +180,54 @@ def test_guardian_rejects_non_allowlisted_environment_without_acknowledging(assert not acknowledgement.exists()-def test_guardian_rejects_desktop_session_variables_from_child_environment(+def test_guardian_forwards_graphical_session_handles_to_the_child(tmp_path: Path,) -> None:+ """Codex must be able to open the OAuth page itself on Linux.++ Windows (ShellExecute) and macOS (``open``) always could; the login child+ on Linux could not, because the display handles the guardian itself has+ were stripped from the environment it hands to Codex. The user was left+ copying a device-code URL out of a terminal — a Linux-only degradation of+ the same flow. These are session handles, never credentials.+ """+ profile = tmp_path / "profile"+ profile.mkdir()++ environment = codex_login_guard._strict_environment(+ json.dumps(+ {+ "CODEX_HOME": str(profile),+ "DISPLAY": ":0",+ "WAYLAND_DISPLAY": "wayland-0",+ "XAUTHORITY": "/run/user/1000/gdm/Xauthority",+ "XDG_RUNTIME_DIR": "/run/user/1000",+ "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/1000/bus",+ }+ )+ )++ assert environment["DISPLAY"] == ":0"+ assert environment["WAYLAND_DISPLAY"] == "wayland-0"+ assert environment["XDG_RUNTIME_DIR"] == "/run/user/1000"+++def test_guardian_still_rejects_unapproved_session_variables(+ tmp_path: Path,+) -> None:+ """Admitting the display handles must not widen the allowlist generally."""profile = tmp_path / "profile"profile.mkdir()with pytest.raises(ValueError, match="not approved"):codex_login_guard._strict_environment(- json.dumps({"CODEX_HOME": str(profile), "DISPLAY": ":0"})+ json.dumps(+ {+ "CODEX_HOME": str(profile),+ "DISPLAY": ":0",+ "XDG_CURRENT_DESKTOP": "GNOME",+ }+ ))