Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils xvfb xauth
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils xvfb xauth xdotool

- name: Install uv
uses: astral-sh/setup-uv@v5
Expand Down Expand Up @@ -249,12 +249,17 @@ jobs:
assert parse_qs(url.query) == {"bind_session": ["smoke"]}, url
print("both windows rendered the app shell")
PY
# TD-5427: the host heard the ready signal, so the window painted.
LOG="$HOME/.local/share/tst-desk/logs/host.log"
grep "main window painted" "$LOG" || {
echo "::error::the packaged app's window never sent the ready signal"; tail -20 "$LOG"; exit 1; }

# The 0.5.4 start-up failure: a long-used install (183 chats) never
# connected, because every chat was revived before the daemon wrote
# port.json and the host gave up after 30 s. Gate every release on a
# data folder like that one: 300 chats, long event logs, a project
# tree each. The packaged app must connect within 10 s of launch.
# tree each. The packaged app must connect within 10 s of launch, and
# its window must paint (TD-5427: a blank window also connects).
- name: Gate a long-used install's start (Linux)
if: runner.os == 'Linux'
run: |
Expand All @@ -274,11 +279,13 @@ jobs:
APP=$!
# Watch for up to 60 s so a miss reports how long it really took.
ELAPSED=""
PAINTED=""
for i in $(seq 1 600); do
if grep -q "connected to tstd" "$LOG" 2>/dev/null; then
if [ -z "$ELAPSED" ] && grep -q "connected to tstd" "$LOG" 2>/dev/null; then
ELAPSED=$(python3 -c "import sys,time; print(round(time.time() - float(sys.argv[1]), 2))" "$START")
break
fi
if grep -q "main window painted" "$LOG" 2>/dev/null; then PAINTED=yes; fi
if [ -n "$ELAPSED" ] && [ -n "$PAINTED" ]; then break; fi
sleep 0.1
done
kill "$APP" 2>/dev/null || true
Expand All @@ -289,8 +296,21 @@ jobs:
tail -20 "$DATA/logs/tstd.stderr.log" 2>/dev/null || true
tail -20 "$OUT" || true
[ -n "$ELAPSED" ] || { echo "::error::the packaged app never connected to tstd on a 300-chat data folder"; exit 1; }
[ -n "$PAINTED" ] || { echo "::error::the packaged app's window never sent the ready signal (60 s)"; exit 1; }
if grep -q "relaunching once" "$LOG"; then
echo "::warning::the window painted only after a relaunch without compositing"
fi
python3 -c "import sys; sys.exit(0 if float(sys.argv[1]) <= 10 else 1)" "$ELAPSED" || { echo "::error::the packaged app took ${ELAPSED} s to connect to tstd on a 300-chat data folder (limit 10 s)"; exit 1; }

# TD-5427: with EGL made to fail, the packaged app either relaunches
# and paints or says why in a dialog and exits 1. Never a blank window.
- name: Force an EGL failure on the packaged Linux app
if: runner.os == 'Linux'
run: |
set -e
AI=$(ls "$PWD"/shell/target/release/bundle/appimage/*.AppImage)
shell/scripts/egl-fallback-smoke.sh "$AI"

- name: Smoke the bundled sidecar (Windows)
if: runner.os == 'Windows'
shell: pwsh
Expand Down
83 changes: 83 additions & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22344,3 +22344,86 @@ field plus plumbing through dispatch; and the audit pairs a result, a card
and a decision with its call by id, so the second call's row and result
would still be ambiguous there. Two calls alike in one reply is a provider
fault; showing both runs on their own, in both views, says what is known.

---

### TD-5427: a web view that cannot draw

**The whole app is replaced, not the web view.** WebKitGTK reads
`WEBKIT_DISABLE_COMPOSITING_MODE` once, in the UI process, and holds the
answer for the life of that process, so a new web view would not see it. The
host stops tstd and the embeddings sidecar as Quit does, releases the
single-instance name and `exec`s its own binary with the same arguments. The
process id stays, so a launcher, the AppImage runtime and tstd's
`--parent-pid` still name the app, and there is no second instance to race.
The wait for tstd has no limit of its own: a tstd still starting is stopped
once it answers, so the next one finds the data folder free; the supervisor
already bounds that start. The cost is that the old web view's helper
processes stay as zombies until the relaunched app exits.

**At most one relaunch per start.** The relaunched process carries
`TST_DESK_COMPOSITING_RELAUNCH=<reason>`, read and removed before any thread
starts. A process with that mark, or with the compositing variable set to
anything at all, goes to the dialog instead. The updater drops the variable
from the process that applies an update when the host set it, so the new
version does not take it for the person's choice.

**The ready signal is two animation frames after the root layout mounts**
(`ui_painted`, main window only). The first callback runs before its frame is
drawn; the second shows one was. It is evidence that the web process runs
frames, not a reading of the pixels on screen.

**N is 20 s** (`TST_DESK_PAINT_TIMEOUT_SECS` overrides it, for tests). A dead
web process is acted on at once through WebKitGTK's
`web-process-terminated`; Tauri reports that on Apple platforms only, so the
host connects the signal itself. The timer is for a view that stays alive and
silent. Healthy starts signalled in about 1 s on the test machine; the wait is
long because a false positive restarts the app, and a second one ends it. A
hidden or minimised window draws no frames, so it is not judged until shown.

**After the first paint nothing is relaunched.** The requirement is a start
that never draws. A later crash of the web process is logged.

**The web process's last words come through a stderr relay.** WebKitGTK
starts that process itself and it inherits the host's stderr. Before GTK
starts, the host forks (twice, so no zombie) a small copier that passes
stderr on unchanged and gives the host a second copy, from which the last
abort or graphics-failure line is kept. A process rather than a thread: if the
host aborts, its message still reaches the terminal, and no writer gets a
broken pipe after the host exits.

**The failing exit code is set by the host.** Tauri's `exit(code)` ends with
status 0 on Linux whatever the code, so a quit after the dialog runs the same
cleanup and calls `process::exit(1)`.

**Doctor learns of it from the daemon's environment.** The host sets
`TST_DESK_DISPLAY_NOTICE=<reason>` on the tstd it spawns; the daemon takes it
out of its own environment and adds a `display` row (warn). No file, so no
stale row after a normal start. A daemon the host attached to rather than
spawned has no row.

**The remedy does not cure every EGL failure.** Tested: with an EGL vendor
file naming a missing library, the web process aborts with or without
compositing, so that start ends in the dialog. A Mesa override that breaks GL
context creation (`MESA_GLES_VERSION_OVERRIDE=1.0` with the Mesa vendor file)
leaves the view silent with compositing and drawing without it; the smoke
script uses one of each. No other variable is set: only the one asked for.

## 2026-12-01 — TD-5427: review round 1 (Class A)

- **The dialog's OK ends the process** (`end_process`): it called
`request_quit`, which does nothing once the relaunch has begun a quit, so
a failed relaunch left a hidden process running.
- **The dialog text is escaped for GTK** (`%` doubled, NULs stripped on
Linux): rfd hands the message to GTK as a printf format, so a `%` in an
environment variable or a path crashed the dialog.
- **Quit wins over a waiting relaunch.** A relaunch waits, unbounded, for a
starting tstd to stop (a tstd mid-upgrade is never killed); a tray Quit
during that wait used to do nothing and the app relaunched anyway. Now Quit
cancels the relaunch and the process ends. The window stays empty during
that wait; that is disclosed, not hidden.
- **Disclosed, not fixed:** GTK3 on Wayland cannot report "minimised", so a
window minimised before its first paint may be judged blank and relaunched
once; and after a failed relaunch with no EGL override set, the dialog names
the variable already tried but no other fix.

40 changes: 40 additions & 0 deletions core/tests/test_display_notice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Doctor's ``display`` row after the host relaunched its window (TD-5427)."""

from __future__ import annotations

import os
from pathlib import Path

import pytest

from tstd import display_notice

from .test_diagnostics import _report, _row

_REASON = "the web process crashed"


def test_the_reason_is_taken_once_so_nothing_else_inherits_it() -> None:
env = {display_notice.NOTICE_ENV: f" {_REASON} ", "PATH": "/bin"}
assert display_notice.take(env) == _REASON
assert env == {"PATH": "/bin"}
assert display_notice.take(env) is None


async def test_doctor_says_the_window_was_relaunched(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.setenv(display_notice.NOTICE_ENV, _REASON)
row = _row(await _report(tmp_path), "display")
assert row["status"] == "warn"
assert row["detail"] == (
"relaunched without compositing because the web view did not draw (the web process crashed)"
)
assert display_notice.NOTICE_ENV not in os.environ


async def test_doctor_has_no_display_row_without_a_relaunch(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.delenv(display_notice.NOTICE_ENV, raising=False)
assert "display" not in [c["name"] for c in await _report(tmp_path)]
10 changes: 8 additions & 2 deletions core/tstd/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
cu_gate,
cu_stopfile,
data_backup,
display_notice,
fast_switch,
keychain_mcp,
managed_guard,
Expand Down Expand Up @@ -1388,6 +1389,8 @@ def __init__(
# so a step stuck on an await reads as a stall to the host.
self.start_heartbeat = start_heartbeat
self.data_dir = data_dir or user_data_dir()
# TD-5427: why the desktop host relaunched its window, if it did.
self._display_notice = display_notice.take()
# UPGRADE-02: first, before any store opens. A folder a newer version
# wrote is read-only for this process: nothing in it changes.
found = stamped_format(self.data_dir)
Expand Down Expand Up @@ -2833,8 +2836,9 @@ def walk(node: object) -> None:
async def _diagnostics_report(self) -> DiagnosticsReport:
"""Run the doctor checks (TD-1104) and return the report.

Rows in display order: daemon → key → provider → git → grok_cli →
workspace → steering → skills → optional ``mcp:<id>`` (only when
Rows in display order: daemon → ``display`` (only after a relaunch,
TD-5427) → key → provider → git → grok_cli → workspace → steering →
skills → optional ``mcp:<id>`` (only when
``mcp.servers`` is non-empty). Blocking filesystem calls ride
worker threads; the live provider probe is the only slow row (one
token, worst case the provider timeout).
Expand All @@ -2850,6 +2854,8 @@ async def _diagnostics_report(self) -> DiagnosticsReport:
detail=f"responding (v{self._version()}, up {self.state.uptime:.1f}s)",
)
]
if self._display_notice:
checks.append(display_notice.doctor_row(self._display_notice))

# API key presence first — presence is free, validity needs the probe.
needed: list[str] = []
Expand Down
29 changes: 29 additions & 0 deletions core/tstd/display_notice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Doctor's ``display`` row: the host relaunched its window (TD-5427).

The desktop host sets ``TST_DESK_DISPLAY_NOTICE`` on the daemon it spawns
after relaunching itself because its web view did not draw. The value is the
reason. Without a relaunch there is no variable and no row.
"""

from __future__ import annotations

import os
from collections.abc import MutableMapping

from .protocol import DiagnosticCheck

NOTICE_ENV = "TST_DESK_DISPLAY_NOTICE"


def take(env: MutableMapping[str, str] | None = None) -> str | None:
"""Read and remove the reason, so nothing this daemon starts inherits it."""
source = os.environ if env is None else env
return source.pop(NOTICE_ENV, "").strip() or None


def doctor_row(reason: str) -> DiagnosticCheck:
return DiagnosticCheck(
name="display",
status="warn",
detail=f"relaunched without compositing because the web view did not draw ({reason})",
)
34 changes: 34 additions & 0 deletions docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,37 @@ reply), and AppImage `--appimage-extract` of the same sidecar. It does
not tick the four-platform packaging boxes. macOS and Windows guests use
`core/scripts/smoke_macos_bundle.sh` and `core/scripts/smoke_windows_bundle.ps1`
(TD-4906). GitHub Actions `package.yml` is a separate gate.

---

## 9. A window that cannot draw

A WebKitGTK web process that cannot create an EGL display aborts at start
("Could not create default EGL display: EGL_BAD_PARAMETER. Aborting...").
An EGL vendor override (`__EGL_VENDOR_LIBRARY_FILENAMES`) on a remote-desktop
X display is one way to get there. The window would show its menu and nothing
else, so the app does not leave it that way (TD-5427):

1. The window tells the host when it has drawn its first frame. `host.log`
says `main window painted (UI ready signal)`.
2. If the web process dies first, or no signal comes within 20 s while the
window is shown, the app replaces itself once with
`WEBKIT_DISABLE_COMPOSITING_MODE=1`, keeping its process id. `host.log`
gives the reason, and Doctor shows a `display` row for that run.
3. If that start cannot draw either, an error dialog quotes the log line and
the web process's last graphics error, and the app exits with status 1.
With the variable already set in your environment there is no relaunch:
the dialog comes at once.

Compositing off does not cure every EGL failure. With no usable EGL library
at all, only removing the override or repairing the drivers helps, and the
dialog names `__EGL_VENDOR_LIBRARY_FILENAMES` when it is set.

Each start decides again; nothing is saved. To skip the failed first attempt
on a computer that always needs it, set the variable yourself.
`TST_DESK_PAINT_TIMEOUT_SECS` changes the 20 s wait; it is meant for tests.

A web process that dies after the window has drawn is logged and nothing more.

`shell/scripts/egl-fallback-smoke.sh <AppImage or tst-desk>` forces both
outcomes under Xvfb, and `package.yml` runs it on the Linux AppImages.
13 changes: 13 additions & 0 deletions docs/tst-desk-backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15980,6 +15980,19 @@ A11Y-03's Fix ("make an accidental cancel recoverable") and INTERACT-01 (b), con

**Size:** 1 · **Status:** In review

### TD-5427 — A web view that cannot draw is relaunched without compositing, never left blank

From a live Linux install: the WebKitGTK web process aborted at start ("Could not create default EGL display: EGL_BAD_PARAMETER. Aborting..."), the window showed only the File and Edit menu, nothing said why, and the host still logged "connected to tstd". The manager's requirements:

- [x] The host detects that the web process died or never painted (no ready signal from the UI within N seconds) and relaunches once with compositing disabled. Log that, and say so in Doctor.
- [x] If it still fails, show a native error dialog with the log line and the env var that fixes it, never a blank window.
- [x] The packaged-launch gate in package.yml checks that the UI actually painted (the ready signal), not just that tstd connected.
- [x] A test that forces an EGL failure.

N is 20 s. A web process that dies after the window has painted is logged only: the story is the start. Linux only, since the remedy is WebKitGTK's. See `docs/linux.md` §9.

**Size:** 5 · **Status:** In review

## 0.5.13 — dialogs, keyboard and accessibility (the UI inspection of 2026-11-28, item 11)

The report's "Fix first" item 11: one dialog and keyboard foundation, Undo on Linux, native controls that follow the app's theme, and the four failures a VPAT would have to list as blocking. Each story is one PR with a before/after repro.
Expand Down
Loading
Loading