Skip to content

fix(server): editors opened from a boot-started service get the desktop's session type - #39960

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-36781
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-36781

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

When T3's server runs as a lingering systemd user service that started before the graphical login, readGraphicalSessionEnv in apps/server/src/process/externalLauncher.ts recovers the desktop session's environment from the systemd user manager (over busctl) before launching an editor. It kept only DISPLAY, WAYLAND_DISPLAY and XAUTHORITY. Without XDG_SESSION_TYPE, Electron editors like VS Code fall back to X11 on a Wayland session and render at a different scale. The fix adds XDG_SESSION_TYPE to GRAPHICAL_SESSION_ENV_KEYS, so the launched editor gets the same session type as a desktop launch. It is a one-line change with no new parser or regex. The repro test from factory/repro-36781 (which adds XDG_SESSION_TYPE=wayland to the existing systemd user manager test) is kept: it failed before the change and passes after. The VS Code scale difference itself was not observed, because this VM has no Wayland compositor.

Fixes #36781

Reproduction on main

Commit cebdf39 (origin/main). Started vp run dev with T3CODE_DEV_SEED=0 and DISPLAY, WAYLAND_DISPLAY, XDG_SESSION_TYPE and XAUTHORITY unset, to mimic a lingering systemd user service that started before the graphical login. A stub busctl first on PATH returned what the systemd user manager returns after a Wayland login imports its environment ({"type":"as","data":["HOME=...","WAYLAND_DISPLAY=wayland-1","XDG_SESSION_TYPE=wayland","XDG_CURRENT_DESKTOP=Hyprland"]}). A stub code recorded its environment. In the web client I clicked 'Open in VS Code' in the thread details panel. The editor was launched with --new-window <project> and only WAYLAND_DISPLAY=wayland-1; XDG_SESSION_TYPE was absent even though the user manager provided it. Also extended the existing test 'a Linux editor launch without a display takes the desktop session's display from the systemd user manager' in apps/server/src/process/externalLauncher.test.ts with XDG_SESSION_TYPE=wayland; it fails on main because the launched editor env lacks XDG_SESSION_TYPE. The actual VS Code scale difference on a real Hyprland session was not observed here (no Wayland compositor on the VM); that part rests on the reporter's devicePixelRatio measurements.

Evidence

Being captured: before and after in the real app. This section is filled in before the pull request can merge.

Tests

Before the fix: vp test run src/process/externalLauncher.test.ts -t "systemd user manager" (apps/server) → 1 failed. After: vp test run src/process/externalLauncher.test.ts → 38 passed, 8 skipped. vp run check:changed → format, lint, knip, graphql, typecheck (3 packages), test (2 files) all pass.

Not in this change

  • hasGraphicalLinuxSession still decides whether to read the user manager only from DISPLAY and WAYLAND_DISPLAY. A service that has a display variable but not XDG_SESSION_TYPE still gets no recovery. That case was not reported, so it was left unchanged.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 2 commits November 14, 2026 14:51
…_TYPE

Reproduces #36781: the session display recovered from the systemd user
manager omits XDG_SESSION_TYPE, so Electron editors fall back to X11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…op's session type

Electron editors such as VS Code fall back to X11 on a Wayland session
when XDG_SESSION_TYPE is missing, and render at a different scale.
Recover it from the systemd user manager along with the display variables.

Fixes #36781

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: f2ec853 · PR result: 286f51a · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The systemd user-manager environment recovery now includes XDG_SESSION_TYPE. The test checks that XDG_SESSION_TYPE=wayland appears in the editor launch environment.

Changes: Editor session environment

Layer / File(s) Summary
Recover and pass the session type
apps/server/src/process/externalLauncher.ts, apps/server/src/process/externalLauncher.test.ts
GRAPHICAL_SESSION_ENV_KEYS now includes XDG_SESSION_TYPE. The test expects the recovered Wayland value in the editor environment.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • pingdotgg/t3code#24508: This PR builds on the systemd user-manager environment recovery that #24508 introduced for editor launches.
  • pingdotgg/t3code#33107: This PR changes a key returned by the shared helper used for file manager launches.
  • pingdotgg/t3code#35742: This PR changes a key returned by the shared helper used when spawning integrated terminals and agent shells.

Suggested reviewers: stienswout, macroscopeapp

Merge Risk: Minimal · up to 286f5

Editors launched from a boot-started Linux service can now receive the Wayland session type recovered from the desktop's user manager. The change is small and covered by an updated test, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the actual change: editors opened from a boot-started service now receive the desktop's session type. It matches the diff, which adds XDG_SESSION_TYPE to the recovered graphical sessio…
Description check Passed The description follows the template's main sections: Problem, Change, Scope, Verification, and a note on who did the work. It explains the bug, the one-line fix, and the repro test. It links the issu…
Linked Issues check Passed [#36781] The issue asks that the editor launcher recover XDG_SESSION_TYPE from the systemd user manager when a boot-started service lacks graphical session variables. The PR adds XDG_SESSION_TYPE to G…
Out of Scope Changes check Passed The whole-PR change set is small. It adds one key to GRAPHICAL_SESSION_ENV_KEYS in externalLauncher.ts and extends one existing test in externalLauncher.test.ts with a matching XDG_SESSION_TYPE assert…
Full details: Title check

Explanation

The title names the actual change: editors opened from a boot-started service now receive the desktop's session type. It matches the diff, which adds XDG_SESSION_TYPE to the recovered graphical session environment. It follows the conventional commit form and is specific, though long at 86 characters.

Full details: Description check

Explanation

The description follows the template's main sections: Problem, Change, Scope, Verification, and a note on who did the work. It explains the bug, the one-line fix, and the repro test. It links the issue (#36781) and reports tests run before and after the change. The Evidence section is a placeholder that says before/after capture is pending and must be filled before merge. The template asks for before/after screenshots only for UI changes, so this gap is not a blocker for a server-side fix, but the placeholder should be resolved or removed. The description also has no explicit Problem/Change/Scope headings, so it reads as a free-form write-up that covers those points.

Resolution

Before merging, resolve the "Evidence" placeholder. Either add the captured before/after output or remove the section and state why no evidence applies. Consider using the template headings (Problem, Change, Scope, Verification) so reviewers can find each part.

Full details: Linked Issues check

Explanation

[#36781] The issue asks that the editor launcher recover XDG_SESSION_TYPE from the systemd user manager when a boot-started service lacks graphical session variables. The PR adds XDG_SESSION_TYPE to GRAPHICAL_SESSION_ENV_KEYS in apps/server/src/process/externalLauncher.ts. readGraphicalSessionEnv then reads that key from the user manager, the same path already used for DISPLAY, WAYLAND_DISPLAY and XAUTHORITY. The existing test 'a Linux editor launch without a display takes the desktop session's display from the systemd user manager' now sets XDG_SESSION_TYPE=wayland and expects it in the launched editor environment. The PR reports that this test failed before the change and passes after. The issue suggests testing both Wayland and X11. The added test covers only the Wayland value. The X11 value uses the same code path, so this gap does not block the coding requirement. The issue's scale observation was not reproduced on the VM. That is a runtime observation, not a coding requirement. The file read was truncated before readGraphicalSessionEnv, so the handling of explicit pre-existing values was not directly confirmed in this review. The PR description states the change is additive to the recovery key list.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set is small. It adds one key to GRAPHICAL_SESSION_ENV_KEYS in externalLauncher.ts and extends one existing test in externalLauncher.test.ts with a matching XDG_SESSION_TYPE assertion. Both changes directly implement the recovery requested in #36781. The PR leaves hasGraphicalLinuxSession unchanged and states that choice. No unrelated files or behavior changes appear in the provided summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f2ec853 and 286f51a.

Files selected for processing: 2

  • apps/server/src/process/externalLauncher.test.ts
  • apps/server/src/process/externalLauncher.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@juliusmarminge

Copy link
Copy Markdown
Member Author

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: proving the reported smaller VS Code scale and its correction requires VS Code on a real Wayland/Hyprland session with the affected display scaling configuration. This VM supplies X11 and no Wayland compositor or socket.
  • Environment propagation was not exercised through either running app revision; source inspection alone is not runtime proof.

It stays open for a person to finish or close.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VS Code opens at a smaller scale when T3’s lingering Linux service starts before the Wayland session

1 participant