Skip to content

fix(dashboard): restore the file manager under the installed Linux service - #30083

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
rubencu:fix/linux-service-reveal-desktop-session
Nov 5, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
rubencu:fix/linux-service-reveal-desktop-session

Conversation

@rubencu

@rubencu rubencu commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On a Linux desktop where Kiro Crew runs as the installed service, the dashboard offers "Show in file manager" and "Open with default app" again while a desktop login is live, and a headless host still does not get them.

Since #23019 the dashboard offers those two actions only when the gateway's own environment names a display server (DISPLAY or WAYLAND_DISPLAY). The installed Linux service is a system unit, and its environment never names one. So on every Linux desktop running the service, both actions are hidden and a reveal answers with a clipboard copy. On GNOME they worked before #23019: xdg-open found GNOME through the session bus and ran gio open. The review hold on #23019 raised this, and #30026 tracks it.

Why it matters

Linux desktop users who run the gateway as the installed service lose both actions on every path chip, file view and folder panel, and get the copy fallback instead. #23019 is in v0.12.0-rc.1 through v0.12.0-rc.6, so the stable v0.12.0 would ship the loss.

Not a goal

What changed (motivation → approach → change)

"Show in file manager" and "Open with default app" now follow whether a desktop login is live on the host, not whether the gateway itself was started inside it:

Linux host, xdg-open installed Before After
Installed service, desktop login live hidden, reveal copies offered, xdg-open gets the login's display
Installed service, no desktop login (headless, or after logout) hidden, reveal copies hidden, reveal copies
Gateway started inside the desktop login offered offered, nothing asked

When the gateway's own environment names no display server, desktop_launcher_available() asks the user's systemd manager, which a desktop login fills in. It runs systemctl --user show-environment from the trusted system directories, with a fixed argv, no shell and a 2-second timeout, and with the environment service.common.systemctl_user_env gives every systemctl --user spawn, which fills in the session-bus pointers a unit can lack. The answer is kept for 30 seconds, so a login after the gateway started shows up without a restart.

Only DISPLAY, WAYLAND_DISPLAY, XAUTHORITY, XDG_CURRENT_DESKTOP and KDE_SESSION_VERSION are read. Each passes a plain character check for its kind, with no regular expression: a local :N display, a socket name, an absolute path, desktop names, a one- or two-digit Plasma version. A display counts only while its socket exists (a Wayland name is looked up under the runtime directory service.common.session_runtime_dir resolves), checked again each time a kept answer is used, so a manager still holding a finished login's variables names no session and a logout is seen at once. A reachable session bus alone is never a desktop, which keeps the headless host #23019 fixed hidden and refused.

The launchers pass those values to xdg-open as environment entries, on top of the same session-bus pointers, so a Wayland name resolves where the check found it. The open action asks before its stat-and-launch transaction, so the lookup never runs between the stat and the launch.

KDE and XFCE probably failed under the service before #23019 too. Without XDG_CURRENT_DESKTOP or a display variable, xdg-open finds no opener for them, so the reveal fell back to the clipboard. With this change they get the login's variables wherever their login exports them to the systemd manager. On KDE that includes KDE_SESSION_VERSION, which xdg-open needs to pick kde-open5 or kde-open over Konqueror's kfmclient. That is not verified on a desktop here.

The dashboard spec (docs/system-specs/modules/learn-cron-dashboard.md) describes the lookup. The spawn audit lists the new spawn, and the facade (kiro_crew/platform_compat.py) lists the new names.

Backwards compatibility

Compatible: nothing is renamed, removed or narrowed. desktop_launcher_available() answers True in one more case: no display of its own, and a live desktop session in the user's systemd manager. Only then do the launchers get up to five checked variables, on top of the session-bus pointers systemctl_user_env fills in. One visible side effect: kirocrew open run over SSH on a Linux desktop now opens the desktop app on that desktop, as open does on macOS.

Removes nothing: the change only adds a case where the host answers that it can open a file manager. Every case that answered True still does, and the headless cases still answer False.

Tests

Red on main's code and green here:

  • test/test_reveal_in_file_manager.py::TestDesktopSessionFromTheUserManager::test_a_wayland_login_reaches_the_launcher: the manager's WAYLAND_DISPLAY and XDG_CURRENT_DESKTOP reach xdg-open. Nothing outside the allowlist does, and PATH stays pinned.
  • ...::test_an_x11_login_brings_its_cookie_to_the_default_app: DISPLAY and XAUTHORITY reach the open launcher.
  • ...::test_a_plasma_login_brings_its_session_version: on a Plasma login, KDE_SESSION_VERSION reaches xdg-open with XDG_CURRENT_DESKTOP.
  • ...::test_the_longest_accepted_values_pass: a display with a screen (:12.3), eight desktop names and a two-digit Plasma version are all copied.
  • ...::test_a_malformed_companion_variable_is_left_out (9 cases): a bad XAUTHORITY, XDG_CURRENT_DESKTOP or KDE_SESSION_VERSION is dropped, including a ninth desktop name, a trailing newline and a non-ASCII digit, and the live display still launches.
  • ...::test_the_answer_is_kept_briefly_then_asked_again: a second ask within 30 seconds reuses the answer without a second lookup, and after 30 seconds a new login is seen.
  • ...::test_a_logout_is_seen_on_a_kept_answer: once the display's socket is gone, a kept answer names no session, so a click right after a logout copies the path. No second lookup runs.
  • ...::test_a_unit_without_session_pointers_still_reaches_a_wayland_login: with no XDG_RUNTIME_DIR or bus address in the gateway's environment, the login's Wayland socket is found under the directory session_runtime_dir resolves, and xdg-open gets that directory and the bus with the display. Also red on the previous head's code.
  • test/test_reveal_in_file_manager.py::TestUserManagerLookup::test_it_runs_one_fixed_argv_with_a_timeout and ::test_no_answer_is_no_session (4 cases: no systemctl, a timeout, a refused spawn, a non-zero exit).
  • ...::test_it_gets_the_session_bus_a_unit_can_lack: the lookup's environment is systemctl_user_env's, so the filled-in XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS reach systemctl, with PATH pinned. Also red on the previous head's code.
  • test/test_dashboard_branding.py::TestBrandingEndpoint::test_branding_says_a_linux_host_needs_a_desktop_session[service-under-a-desktop-login]: the whole chain to the branding payload.
  • test/test_dashboard_files_onloop_fs.py::TestBrowseAndReveal::test_the_desktop_question_is_asked_before_the_stat_and_launch: the order is ask, stat, launch, and the ask runs off the loop and outside the probe pool.

Guards, green on main and here: test_a_headless_host_stays_hidden_and_refused (the manager answers with a session bus and no display), test_no_user_manager_stays_hidden_and_refused, test_a_display_whose_server_is_gone_is_not_a_session, test_a_malformed_display_is_not_a_session (10 cases: another machine's display, shell text, systemctl's $'...' quoting, an empty value, a non-ASCII digit, a trailing newline, a path, a .. name, a quoted name, a name with a newline), test_the_gateway_s_own_display_is_used_without_asking (nothing is asked or filled in, not even a bus it could find), test_macos_never_asks, and the branding cases [headless], [headless-with-a-user-bus] and [desktop-session].

The existing tests in TestRevealInFileManager and the branding chain test now start with no user manager to ask, so a developer's own desktop login cannot decide a headless test.

Proof: PROVEN test/test_dashboard_branding.py::TestBrandingEndpoint::test_branding_says_a_linux_host_needs_a_desktop_session[service-under-a-desktop-login], test/test_dashboard_files_onloop_fs.py::TestBrowseAndReveal::test_the_desktop_question_is_asked_before_the_stat_and_launch, test/test_platform_compat_refactor_facade.py::test_every_moved_name_is_defined_by_its_owner_and_read_through_the_facade[kiro_crew.platform_compat_trust-_ASCII_ALNUM], test/test_platform_compat_refactor_facade.py::test_every_moved_name_is_defined_by_its_owner_and_read_through_the_facade[kiro_crew.platform_compat_trust-_WAYLAND_NAME_CHARS], test/test_platform_compat_refactor_facade.py::test_every_moved_name_is_defined_by_its_owner_and_read_through_the_facade[kiro_crew.platform_compat_trust-_XAUTHORITY_CHARS] (head ebfce65)

Determinism: the 140 new and changed node ids ran green 20 of 20 times at -n0, and 10 of 10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test/test_cli_open.py and test/test_dashboard_handlers_core_coverage.py. They were also green in a shuffled order (seed 7867).

Manual verification

  • This host is headless, so no real GNOME login was captured: no systemctl --user show-environment output from a live login, no branding answer of desktop_launcher: true from one, and no reveal through the system unit. No KDE or XFCE login was captured either.
  • The tests feed in a login's output instead. A GNOME Wayland login is WAYLAND_DISPLAY=wayland-0 with XDG_CURRENT_DESKTOP=ubuntu:GNOME, and an empty wayland-0 file stands in for its socket under a temporary XDG_RUNTIME_DIR. An X11 login is DISPLAY=:1 with XAUTHORITY=/run/user/1000/gdm/Xauthority and an X1 file in a temporary X11 socket directory. A Plasma login is XDG_CURRENT_DESKTOP=KDE with KDE_SESSION_VERSION=5. A patched subprocess.Popen records the argv and environment xdg-open would get, and the branding test reads desktop_launcher from the real handler with the Wayland answer.
  • On this headless host, the real lookup answered in 7 to 8 ms. Its first call also imports service.common once, 16 ms here. The user manager's environment held DBUS_SESSION_BUS_ADDRESS and XDG_RUNTIME_DIR but no display, and the session came back empty.
  • Gate floor: the prepare-PR profile's gates[], the repo Semgrep rules plus CI's registry packs (diff-scoped, 0 new findings), and the flake-pattern ratchet. Every gate passes except the backend related-tests gate. Its failures on this host fail the same way on a clean checkout of the base.

Related Issues

Closes #30026

Related: #23019 (added the display check), #30068 (the same blind spot in an app's Open action), #16520 (which environment an app's open command should get).

Sibling sweep

Swept: git grep -nE 'environ(.get)?(?[?"(DISPLAY|WAYLAND_DISPLAY)"' -- src/kiro_crew, and the desktop launchers in src/kiro_crew/dashboard/file_api/desktop.py
Sibling: src/kiro_crew/platform_compat_trust.py:906 -- changed here
Sibling: src/kiro_crew/apps/routes_enable.py:747 -- tracked in #30068
Sibling: src/kiro_crew/cli.py:157 -- not affected -- it decides whether a gateway started from a terminal opens a browser, and the installed service always starts with --no-open
Sibling: src/kiro_crew/slack/gateway_runtime/service_boot.py:1392 -- not affected -- the same browser auto-open at gateway start, which --no-open turns off under the service
Sibling: src/kiro_crew/cloud/login.py:1202 -- not affected -- a sign-in's browser open; when it declines, the sign-in shows its URL to follow
Sibling: src/kiro_crew/cloud/connect.py:506 -- not affected -- the same sign-in browser open, which shows its URL to follow when it declines
Sibling: src/kiro_crew/dashboard/file_api/desktop.py:142 -- not affected -- the native file picker and the screenshot route are macOS only

Pattern harvest

Rule candidate: review-prompt
Pattern: a desktop-session check reads only the gateway's own environment (DISPLAY / WAYLAND_DISPLAY), which a gateway installed as a system service never inherits.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@rubencu
rubencu requested review from a team and KiroCrewCaptain as code owners November 5, 2026 01:04
@rubencu
rubencu requested a review from bolichen97 November 5, 2026 01:04
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Nov 5, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on 5cda130 for one blocking point. CI is still starting on this head, and I read the whole change.

platform_compat_trust.py, _DESKTOP_SESSION_VALUES

The PR adds import re and four compiled patterns (DISPLAY, WAYLAND_DISPLAY, XAUTHORITY, XDG_CURRENT_DESKTOP). _desktop_session_from runs fullmatch on each value read from systemctl --user show-environment, and _x11_display_is_live runs it again and reads match.group(1) to build the socket path. These values come from outside the process and end up in the environment of a launched program, so a regex is the wrong tool for the check. The repo asks for exact structural checks here.

The four shapes are small enough to check directly:

  • DISPLAY: require a leading :, then num, dot, screen = value[1:].partition("."). Require num to be ASCII digits, 1 to 4 long. If dot is present, require screen to be ASCII digits, 1 to 4 long. Return the number as an int so _x11_display_is_live does not have to parse it again.
  • WAYLAND_DISPLAY: length 1 to 64, the first character is a letter, digit or underscore, and every character is in a fixed set of letters, digits, _, . and -.
  • XAUTHORITY: starts with /, length 2 to 1024, every character in the set of letters, digits, _, ., +, / and -, and no .. part (you already check that).
  • XDG_CURRENT_DESKTOP: value.split(":") gives 1 to 8 parts, each 1 to 64 characters from letters, digits, _ and -.

Use str.isascii() with isdigit() for the numbers, since isdigit() alone accepts non-ASCII digits. The existing tests for good and bad values should pass unchanged, and a case with a non-ASCII digit, a trailing newline and a ninth desktop part would pin the edges.

I have not done the full trust review of the part that reads the user's systemd manager and copies session variables into the launcher environment. I will do it on the next head once the parsing no longer uses a regex.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision ebfce65127aca0eba2e31ac28c493723e5cc33dd touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of ebfce65127aca0eba2e31ac28c493723e5cc33dd via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Restores the reveal/open actions that #23019 hid from the installed service (tracked in #30026). The one premise nobody has checked is KDE support.

Notes

  • Item 5 — inherited: the KDE half rests on an untested claim. The description says "On KDE that includes KDE_SESSION_VERSION … That is not verified on a desktop here." The only defect on record is GNOME, which WAYLAND_DISPLAY/DISPLAY plus systemctl_user_env's bus pointers already cover. Subtraction: drop KDE_SESSION_VERSION and _is_kde_session_version from _DESKTOP_SESSION_CHECKS until someone confirms it on a Plasma login.

What this change ships

Inventory (9 items) — 7 justified

Intent: Linux desktop users running the installed service get "Show in file manager" and "Open with default app" back while they are logged in. This is a FIX.

  1. Under the installed service with a live desktop login, both actions are offered again and open on that desktop — justified
  2. A headless host whose user manager exposes only a session bus still hides and refuses both actions — justified
  3. A login after the gateway started shows up within 30 s, no restart needed — justified
  4. A logout is seen at once, because the display socket is checked again on each use of a kept answer — justified
  5. XAUTHORITY, XDG_CURRENT_DESKTOP and KDE_SESSION_VERSION are passed to xdg-open for KDE/XFCE — rides along, not verified on a KDE desktop
  6. The "Open" click asks the desktop question off the event loop before the stat-and-launch step — justified
  7. kirocrew open over SSH on a Linux desktop now opens on that desktop — rides along, declared, a direct result of item 1
  8. Once a session is found, the launcher's environment is built on systemctl_user_env (bus and runtime dir filled in) — justified
  9. Spawn-audit entry and facade names for the new lookup — justified

[FIRST-PRINCIPLES-REVIEWED] ebfce65

Description read

[DESCRIPTION-READ] 908eccae981170ab79402e329c9f80039ea74f475854681c2947c167519e0762

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of ebfce65127aca0eba2e31ac28c493723e5cc33dd via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns: the fix asks the user's systemd manager only when the gateway's own environment has no display, reusing the existing systemctl_user_env seam, and nothing is taken away.

Notes

  • The SSH side effect the description admits (kirocrew open over SSH now opens on the live desktop) changes host-wide behaviour. It belongs in the user-facing reveal docs, not only in the spec.

[DESIGN-REVIEWED] ebfce65

Description read

[DESCRIPTION-READ] 6f2dcf7b48b220f087095e084dd729d73ec04e477f34ee4bbb979087beb27eb1

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed ebfce65127aca0eba2e31ac28c493723e5cc33dd via the fork AI-review pipeline; updated in place on each push.

Review details

No findings. None of the four candidates holds up against the diff and the repository code.

[OPUS-REVIEWED] ebfce65

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed ebfce65127aca0eba2e31ac28c493723e5cc33dd via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ebfce65

@rubencu
rubencu force-pushed the fix/linux-service-reveal-desktop-session branch from 5cda130 to 39d5482 Compare November 5, 2026 04:02
@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the session lookup copies an allowlist of desktop variables from the user's systemd manager into the xdg-open launch

  • Preserve the KDE session version alongside its desktop name span=454890c958c4

fixed in 39d5482: KDE_SESSION_VERSION joins the allowlist, checked as one or two ASCII digits (_is_kde_session_version in platform_compat_trust.py), and reaches the launcher with XDG_CURRENT_DESKTOP, so xdg-open's KDE opener runs kde-open5 or kde-open instead of Konqueror's kfmclient.
Pinned by test_reveal_in_file_manager.py::TestDesktopSessionFromTheUserManager::test_a_plasma_login_brings_its_session_version; a malformed version is dropped (test_a_malformed_companion_variable_is_left_out, the kde-version cases).
Class: the only other allowlist that forwards XDG_CURRENT_DESKTOP is the app openCommand's env list in apps/routes_enable.py, a separate path for manifest-authored shell that #30068 tracks.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

On the review of 5cda130: the session parsing in 39d5482 uses no regular expression. Each value has a plain check with the rules you gave, in platform_compat_trust.py: _x11_display_number, _is_wayland_socket_name, _is_xauthority_path and _is_desktop_names. Digits use isascii() with isdigit(), and _x11_display_number returns the int that _x11_display_is_live takes. The earlier good and bad cases pass unchanged, and new cases pin a non-ASCII digit, a trailing newline and a ninth desktop name.

Two other changes on this head:

  • KDE_SESSION_VERSION is copied too, as one or two ASCII digits, for the GPT lane's KDE finding. With it, xdg-open on Plasma runs kde-open5 or kde-open instead of Konqueror's kfmclient.
  • The display socket is checked again each time a kept answer is used, so a click right after a logout copies the path.

This host is headless, so no real GNOME login was captured: no show-environment output from a live login and no reveal through the system unit. The tests feed in a login's output instead (WAYLAND_DISPLAY=wayland-0 with XDG_CURRENT_DESKTOP=ubuntu:GNOME, DISPLAY=:1 with an XAUTHORITY path, and XDG_CURRENT_DESKTOP=KDE with KDE_SESSION_VERSION=5). Empty files stand in for the display sockets, and a patched subprocess.Popen records what xdg-open would get.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 5, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 5, 2026
…rvice

The installed Linux service is a system unit, so the gateway's own
environment never names a display server. Since kirodotdev#23019 that hid "Show in
file manager" and "Open with default app" on every Linux desktop running
the service, including GNOME, where xdg-open used to reach Nautilus over
the session bus.

When the gateway's own environment names no display, ask the user's
systemd manager (`systemctl --user show-environment`, 2 s timeout, answer
kept for 30 s), run with the environment `systemctl_user_env` gives
every `systemctl --user` spawn. Copy only DISPLAY, WAYLAND_DISPLAY,
XAUTHORITY, XDG_CURRENT_DESKTOP and KDE_SESSION_VERSION, each passing a
plain character check, and count a display only while its socket exists,
checked again on every use of a kept answer. The launcher gets them on
top of the same session-bus pointers. A reachable session bus alone is
not a desktop, so a headless host stays hidden and refused. The open
action asks before its stat-and-launch transaction, so no spawn lands
inside it.

Closes kirodotdev#30026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the regexes are gone and the checks are explicit now. One blocking point is left at 39d5482, and the First Principles Review check is red on it. I checked it against main, and it is more than a duplicate: it likely breaks the case this PR is for.

platform_compat_trust.py, _user_manager_environment

The new spawn runs systemctl --user show-environment with env = dict(os.environ) and only PATH pinned. Main already has systemctl_user_env() in service/common.py, which every other systemctl --user spawn in the codebase uses (the pod runtime, the service verbs, the gateway restart). Its docstring explains why: a process started from a systemd system unit, which is how the installed Linux service runs the gateway, inherits neither XDG_RUNTIME_DIR nor DBUS_SESSION_BUS_ADDRESS, so a bare systemctl --user fails with "Failed to connect to bus: No medium found" even though the user manager is running. That is exactly the situation this PR targets (the installed service, no login environment). With the PR's environment the call is likely to return a non-zero exit, the answer becomes "no session", and the actions stay hidden. The tests mock the spawn, so they would not show it.

Suggested fix: build the child environment with systemctl_user_env() and then pin PATH as you do now. That removes the second copy, and the bus pointers are filled in only when the bus socket exists. Add a test that the spawned environment carries those pointers when the gateway's own environment has none (for example by patching session_runtime_dir).

The rest reads fine to me after the trust review: fixed argv, trusted binary path, timeout, checked values for five keys only, and every failure ends as "no session". GPT 6.1 reports no blocking findings on this head. I will approve once the spawn uses the shared environment helper.

@rubencu
rubencu force-pushed the fix/linux-service-reveal-desktop-session branch from 39d5482 to ebfce65 Compare November 5, 2026 06:13
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 5, 2026
@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the session lookup spawns systemctl --user show-environment to read a desktop login's display variables from the user's manager

  • The spawn's environment is a second copy of systemctl_user_env (duplicate) span=d01d50a35fe8

fixed in ebfce65: _user_manager_environment takes its environment from kiro_crew.service.common.systemctl_user_env (imported inside the function, because service.common imports config.loader, which imports this module) and pins PATH on top. Pinned by test_reveal_in_file_manager.py::TestUserManagerLookup::test_it_gets_the_session_bus_a_unit_can_lack.
Class: two more sites in this path read the same pointers from the gateway's own environment, and both use the resolvers now. The Wayland socket check uses session_runtime_dir, and a launch that uses the manager's session starts from systemctl_user_env, so xdg-open gets the runtime directory and bus the check relied on (test_a_unit_without_session_pointers_still_reaches_a_wayland_login). A gateway with its own display launches unchanged (test_the_gateway_s_own_display_is_used_without_asking).
Other systemctl --user spawns that predate this PR also inherit the process environment (shared_crew/containment.py, session_scope_reap.py, dev_fleet's gateway_service.py and live.py); they are outside this PR's goal.

@rubencu

rubencu commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Changes since 39d5482, now in ebfce65 (rebased onto main 3736af2, still one commit). They answer the First Principles lane's finding that the systemctl --user lookup built its own environment instead of using service.common.systemctl_user_env.

  • src/kiro_crew/platform_compat_trust.py: _user_manager_environment takes its environment from systemctl_user_env, with PATH pinned on top. _wayland_display_is_live looks under session_runtime_dir, and _reveal_env starts from systemctl_user_env when it uses the manager's session. The imports sit inside those functions, because service.common imports config.loader, which imports this module.
  • test/test_reveal_in_file_manager.py: new TestUserManagerLookup::test_it_gets_the_session_bus_a_unit_can_lack and TestDesktopSessionFromTheUserManager::test_a_unit_without_session_pointers_still_reaches_a_wayland_login, both red on 39d5482's code. test_the_gateway_s_own_display_is_used_without_asking now also checks that nothing is filled in.
  • test/spawn_audit_helpers.py: the lookup's row comment names the resolver and says five variables, not four.
  • docs/system-specs/modules/learn-cron-dashboard.md: the Reveal paragraph names both resolvers, and says that kirocrew open run over SSH on a Linux desktop with a live login opens on that desktop.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving ebfce65. Both blocking points from my earlier reviews are fixed on this head.

[Security: this change reads the user's systemd manager environment to find a live desktop session and copies five checked variables into the environment of a file manager launch. It refuses nothing that works today and adds no new restriction. The input is parsed with exact checks and every failure ends as "no session", as below.]

What I checked on this head:

  • Every check passes except PR Readiness, which is still running. The checks that showed as cancelled have newer passing runs. The fork review lanes (Design, First Principles, Opus 5.5, GPT 6.1, Security Scope, Internal Content Scan) all pass or report no blocking findings on this exact head.
  • The four regexes are gone. The session values are checked with explicit rules: a local display number of 1 to 4 ASCII digits with an optional screen, a Wayland socket name (never a path), an X cookie path with no .. part, one to eight desktop names, and a one or two digit Plasma version. No pattern is added.
  • The systemctl --user show-environment spawn now builds its environment with systemctl_user_env() from service/common.py, the helper every other systemctl --user call uses, so the session bus pointers are present under the installed system service. The tests check that environment.
  • Trust review: the argv is fixed, the binary comes from the trusted directories, no shell is involved, the call has a 2 second timeout and a short cache, and only five named keys are read. A display counts only while its socket exists, so a finished login names no session, and a headless host stays at "no actions offered". Values from the manager are only used when the gateway's own environment names no display, so a gateway started inside the desktop login behaves as before. The values only reach the launcher environment, never a shell or the request.

@bolichen97
bolichen97 enabled auto-merge (squash) November 5, 2026 08:16
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 5, 2026
@bolichen97
bolichen97 merged commit 1b8a195 into kirodotdev:main Nov 5, 2026
159 of 169 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 5, 2026
@rubencu
rubencu deleted the fix/linux-service-reveal-desktop-session branch November 5, 2026 11:23
buluoray pushed a commit that referenced this pull request Nov 8, 2026
…rvice (#30083)

The installed Linux service is a system unit, so the gateway's own
environment never names a display server. Since #23019 that hid "Show in
file manager" and "Open with default app" on every Linux desktop running
the service, including GNOME, where xdg-open used to reach Nautilus over
the session bus.

When the gateway's own environment names no display, ask the user's
systemd manager (`systemctl --user show-environment`, 2 s timeout, answer
kept for 30 s), run with the environment `systemctl_user_env` gives
every `systemctl --user` spawn. Copy only DISPLAY, WAYLAND_DISPLAY,
XAUTHORITY, XDG_CURRENT_DESKTOP and KDE_SESSION_VERSION, each passing a
plain character check, and count a display only while its socket exists,
checked again on every use of a kept answer. The launcher gets them on
top of the same session-bus pointers. A reachable session bus alone is
not a desktop, so a headless host stays hidden and refused. The open
action asks before its stat-and-launch transaction, so no spawn lands
inside it.

Closes #30026

(cherry picked from commit 1b8a195)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux service install: "Show in file manager" is hidden on a GNOME desktop since #23019

2 participants