Skip to content

fix(desktop,mobile,remote): timezone-aware task forms, revocable invitations, portable build steps - #1308

Merged
huichen merged 21 commits into
mainfrom
pr/huichen
Oct 22, 2026
Merged

huichen merged 21 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Fix a batch of defects reported against the desktop and mobile apps, and make the build/test plumbing work on any shell. The scheduled-task form now picks a real timezone on both surfaces, a cancelled invitation is actually revoked, a detached peer leaves cleanly, and the proto/docs regeneration flags no longer depend on a POSIX-only prefix. The same batch steadies two flaky tests (a phone unpair's epoch, the shell timeout test) and drops the Westlake HPC guide together with the bilingual debt it carried.

Commits

  • fix(desktop,ci): stop a forked child from reading as an active update; retry a stalled apt mirror
  • test(shots): capture the three surfaces this change touches
  • test(remote): decide a phone unpair's epoch before its cleanup, not by racing it
  • fix(screenshots): make the orphan sweep work on Windows
  • fix(build): pass the proto regeneration flag without a POSIX-only prefix
  • fix(apps): a cancelled invitation is revoked, a detached peer leaves, and the task form names zones
  • fix(build): set the docs-test bytecode flag without a POSIX-only prefix
  • docs: drop the Westlake HPC guide and close the bilingual debt it carried
  • fix(mobile): align the scheduled-task form with the desktop's
  • fix(mobile): keep a standby desktop's settings out of reach
  • test(agent): give the shell timeout test room for PowerShell startup

Verification

  • cargo fmt --all -- --check → clean at the branch tip on the pinned toolchain (rustc 1.97.0).
  • CI run 39806359453 is the matrix check for this head: Rust fmt/clippy/tests on Linux, macOS and Windows, plus desktop/mobile TypeScript checks, vitest, and the mobile device tests.
  • The earlier head of this PR (7d86b95af) had every job green except the two desktop jobs, which died in the apt setup step Install Linux GUI dependencies with exit code 124 (a 180-second download timeout on a slow Ubuntu mirror, no project step ran). The last commit makes scripts/ci/install-apt-packages.sh retry a stalled mirror, so this run exercises that path.

Notes

  • Screenshot fixtures under scripts/screenshots/ and desktop/shot/mock/ grow with the new timezone surfaces; the generated captures stay gitignored.
  • docs/hpc-westlake-guide.zh-CN.md is removed, which closes the bilingual-pairing debt that document carried.

huichen and others added 6 commits October 22, 2026 21:20
`timeout_retains_partial_output_without_fabricated_exit` starts PowerShell on a
one-second deadline, so on a loaded Windows runner the window can close while
PowerShell is still starting up and the test reports the timeout property as
broken. It failed that way on 2026-10-22 (run 39779594808, `Rust Windows test /
agent`) on a commit that passed on macOS and Linux.

Nothing in the product changed: the same four assertions, the command still
sleeps far past the deadline, and POSIX keeps its one-second window. Only the
Windows deadline moves to 8s — eight times the window that lost, which is the
only measurement the failure gives (the cold start did not fit in 1s) — and the
failure message now reports the tool's own duration, the wall clock and the
output actually captured, so a slow shell start and dropped output stop looking
identical in the log. A new upper bound fails the test if a call returns well
past its deadline, which a never-returning timeout would otherwise turn into a
slow pass.
A machine another device drives refuses every command before a handler runs, so
the device page's five rows opened a stack of dead ends: greyed-out switches
under a "could not read the desktop" line, and approval radios that only asked
whether the machine was online — a tap wrote a command the host answers with
`superseded`.

Those rows are no longer drawn while `presence.control === "standby"`: the
banner above them (holder, reason, takeover) is what the page keeps, and the
machine's name and icon stay editable because they are this phone's own record
of it. A level already open when control is taken gives way to that banner and
returns in the same render once this phone has the machine again, and the
approval write is refused in its handler rather than only at the route.
The phone's editor was an approximation of the desktop's, and the differences
were load-bearing:

- A new task started on "manual", which is the one trigger that never fires
  (`TriggerKind::Manual` has no next due time) — and the phone has no run-now
  button either, so the task it built by default could not run at all. New
  tasks now pick a trigger and are refused without one; a task that is already
  manual keeps its option, so an edit round-trips.
- "Weekly" was a text field asking the user to spell `mon, fri`; it is the same
  seven toggles the desktop draws, stored in week order.
- A one-off's date was a text field whose `2026-12-24` placeholder read as a
  date already chosen — the trap the desktop removed with a picker. `DateField`
  is the same choice in three chip rows, with days that follow the month.
- The time zone sat outside the trigger and offered four hard-coded names. It
  belongs to the schedule, so it now sits inside the trigger and only for a
  mode that reads a clock, listing every zone the runtime knows, with a search
  field; a zone the task already carries is kept even if the list lacks it.
- The list row rendered `nextDueAt` on the *phone's* clock while the desktop
  rendered it on the task's, so the two clients named different wall clocks for
  the same run. `list_tasks` now carries the row's `timezone`, and the row is
  formatted on it.

Backing out of the form also kept discarding the draft: the system gesture and
the header arrow are how a phone leaves a screen, and an interrupted form is
exactly why the draft exists. Only Cancel and a save that landed clear it now.
@huichen
huichen enabled auto-merge (squash) October 22, 2026 14:20
…ried

`docs/hpc-westlake-guide.zh-CN.md` (#1296) was the repository's only entry in
`BILINGUAL_PENDING`: a Chinese-only guide for one institution's cluster, which
nothing else in the docs refers to. Rather than write an English pair for it, the
page goes and the pending entry with it, so `make check-docs` stops being a
standing red that every unrelated change has to explain — `--strict-pending` now
passes with no debt left.

The gate's third step also failed on Windows, for a reason unrelated to docs:
`check-channel-matrix.py` read the matrix, the registry and each provider with
`read_text()` and no encoding, so a machine whose locale is a legacy code page
could not decode the UTF-8 sources at all (`UnicodeDecodeError: 'gbk' codec …`).
All three reads now state `utf-8`, the same way `check-docs.py` already does.

`BILINGUAL_PENDING` stays a dict literal rather than becoming `set()`:
`scripts/tests/test-check-docs.py` inserts its debt fixture after the opening
brace, and 35 docs-gate regression tests pass unchanged.
`make test-docs-check` could not run on Windows at all:

    PYTHONDONTWRITEBYTECODE=1 python3 scripts/tests/test-check-docs.py
    'PYTHONDONTWRITEBYTECODE' is not recognized as an internal or external command

That `VAR=1 command` prefix is POSIX shell syntax, and a Windows make runs
recipes through cmd.exe, which takes the first word of the line as the program
to run. The flag is now a target-specific exported variable, which make places
in the recipe's environment whatever the shell is — and, unlike a bare
`python3 -B`, the interpreter's own child processes inherit it, which is what
this test needs for the trees it builds and runs.

`test-screenshot-harness` sets the same two flags the same way; it had the same
error, three lines below.

The Makefile stays compatible with the GNU Make 3.81 on this machine, where
target-specific `export` is supported (verified, along with it being scoped to
its own target and inherited by a grandchild process).
… and the task form names zones

Four reports from the desktop defect list, each traced to a cause in the code.

- Add device, then Cancel: the invitation stayed on the platform. An
  unclaimed invitation is not in the pairing book — it enters at the handshake
  — so `unpair_slot` found no credentials and revoked nothing, and the platform
  row kept one slot of the per-desktop cap until its nonce expired. Five
  presses of add and cancel filled that cap with codes nobody could claim, and
  the sixth press was refused over a limit the user had never spent on devices.
  The discard now queues a revoke by the only identifier an unclaimed
  invitation has, its pair id, on the same compensation lane an unpair uses;
  `remove --all` clears them the same way. Delivery is queued rather than
  awaited, so closing the window never waits on the platform.

- The other computer unpaired this one, and its row stayed. The desktop client
  never read the host's own notice: the presence payload's `unpaired` (and
  `disconnected` with that reason) went into `apply_presence`, which only looks
  at `control`. The row therefore survived until somebody pressed Connect and
  the platform refused it. The list now drops the pairing — and its
  registration — when the host says so, and when the platform's own answer to
  a connect is `credential is invalid or revoked`. A machine that is merely
  asleep is left alone: forgetting it would silently unpair a computer that
  comes back when it wakes.

- Take over: "LNA-AL00 is in control" did not say what to do. The row reads
  "Another device (LNA-AL00) is in control"; Settings stays disabled with the
  reason on hover, which #1300 already did.

- Settings → Keyboard shortcuts: the two paragraphs naming the levels and the
  terminal's rule are gone. What is left is the search box, the reset button
  and the list.

- Scheduled tasks, time zone: a picker of four hundred English identifiers
  named the region and nothing else. Each row is now the zone's name in the UI
  language plus its offset (`中国时间 · UTC+8`), this machine's zone and the
  common ones lead, the rest run west to east, and a search box answers a
  name, an identifier, a city or `+8`. The stored value stays the IANA name,
  so changing the interface language never rewrites a schedule.

Docs record the two rules that changed: a discarded invitation is deleted on
the platform, not just forgotten here, and a zone is read in the reader's
language while the identifier remains what is saved.
…ched peer leaves, and the task form names zones)
`make generate-proto` could not regenerate anything on Windows: the recipe wrote
`REGENERATE_PROTO=1 cargo build`, a POSIX shell prefix that cmd.exe reads as the
program name, so the build script never saw the variable and the targets failed
with `'REGENERATE_PROTO' is not recognized as an internal or external command`.

It is now a target-specific exported variable, which make puts in the recipe's
environment whatever the shell is. Verified on Windows: the build script now
receives it (it gets past its "not requested" early return and looks for protoc,
which it never did before), and a full run with a temporary protoc on PATH
regenerated both wire files byte-identically — `git status` shows no change
under packages/rpc/src/generated or channels/src/generated.
The screenshot harness reaps browsers and `future-shot-` profiles that killed
runs left behind, and on Windows it could not: `list_processes()` shells out to
`ps -Ao`, which does not exist there, so it returned an empty list and the sweep
was a silent no-op — every interrupted run kept its browser and its 130-160 MB
profile, exactly the defect the sweep was written for.

The listing now comes from `Get-CimInstance Win32_Process` on Windows (as JSON,
asked for as UTF-8 so a non-ASCII temp path is not mangled), because the two
fields it needs — the parent id and the command line — are in neither `ps` nor
`tasklist`.

Orphan detection had the same POSIX assumption: it required `ppid == 1`, which
is what re-parenting to init looks like. Windows does not re-parent, so an
orphan there still names its dead launch. `parent_is_gone` therefore accepts
either form — re-parented to init, or a parent that is no longer in the listing
— and still cannot select a browser whose capture is running.

`os.kill(pid, signal.SIGTERM)` is the same call on both platforms; on Windows it
is `TerminateProcess`, which is the outcome the sweep wants for a browser whose
run is already gone. The SIGTERM *handler*, on the other hand, can never run on
Windows (`os.kill` terminates the process outright), so it is now POSIX-only and
says so — there the startup sweep is the guarantee, and `ReapTests` exercises it
on both platforms.

The tests lost two POSIX assumptions of their own: `process_absent` probed
liveness with `os.kill(pid, 0)`, which on Windows neither raises for a dead pid
nor sends anything (it could only ever time out), so existence now comes from
`OpenProcess`; and the signalled-exit case is skipped on Windows with the reason
above rather than silently failing. 17 tests pass here, 1 skipped.
…y racing it

`an_unpair_whose_epoch_was_revoked_leaves_the_pairing_alone` failed about one
run in five. It asserted that a phone-initiated unpair leaves the pairing alone
after its epoch was revoked, and set the revoked state *after* the command
returned — on the premise that the test's current-thread runtime had not
scheduled the spawned cleanup yet.

That premise is false. The supervisor's executor is `DesktopExecutor`, which
spawns on the process-wide runtime, so the cleanup runs on another thread
concurrently with the test. Whichever side the scheduler picked decided the
outcome: with a live epoch the cleanup legitimately cleared the pairing, and the
assertion fired against behaviour that was correct.

The two halves now have their own tests, because they need opposite timing. The
acknowledgement is asserted through the command, which is what proves that path
reaches the cleanup at all; the guard is asserted by calling the same cleanup
under an epoch revoked *before* it starts, where the answer is decided rather
than raced. Both layers of the guard are described where they live: the inner
one (`CommandRuntime::unpair_slot` refuses a dead generation) is the guarantee,
the outer early return only keeps `remote_server_stopped` out of the log.

Verified by removal: with both guards gone the new test fails every run, so it
pins the invariant rather than the absence of a race. 20 consecutive runs of the
pair pass, and no run has failed since.
The screenshots are the evidence, so the fixtures that produce them belong in
the repo: without the scenario rows and the mock state they cannot be re-run.

- `remote-peers-held`: a paired computer another device drives. The mock peers
  gain the `control`/`holder` fields the real peer summary carries — absent is
  still "no statement" (an older host), which is what every earlier scenario
  reads — and `?peers=held` marks the first one as held.
- `settings-shortcuts`: the shortcut page without the two paragraphs, asserted
  by their own text so a future edit that puts them back fails the capture.
- `tasks-timezone-picker` / `tasks-timezone-search`: the zone list in Chinese
  with offsets beside each name, and the same list narrowed by `+8`.

The time-zone trigger also gains an accessible name: its content is the chosen
zone ("中国时间 · UTC+8"), which does not say what the control is for, and a
button a scenario cannot address by name is a button whose accessible name is
missing.
… raced; screenshots for the changed surfaces)
@huichen huichen changed the title fix(mobile,agent): task form timezone fields, standby settings, wider shell timeout test fix(desktop,mobile,remote): timezone-aware task forms, revocable invitations, portable build steps Oct 22, 2026
…; retry a stalled apt mirror

Two independent causes of the red required checks on #1308.

`Operation::begin` reported `Another update transaction is active` in CI for a
case that had started no update (run 39802801818, `Rust Linux test / desktop`).
The lease is a file lock, and this process spawns children constantly — the CLI
runner, the installer, terminal shells — so a child forked by another thread
inherits every descriptor that is open at that instant, this lease among them,
and keeps the lock until it execs. The refusal is now reported only after a short
settle window (250 ms in 10 ms steps); a genuinely concurrent installation holds
the lease for minutes, so the outcome for it is unchanged, while a fork-to-exec
gap is microseconds.

`install-apt-packages.sh` rewrote the mirror only when `apt-get update` failed.
A *stalled* download therefore had no fallback at all: `Acquire::http::Timeout`
bounds the socket rather than the transfer and `Acquire::Retries` retries an
error rather than a connection that opens and then crawls, so a run sat on
~2.5 MB from the Azure mirror until the 180 s budget expired and the job died
with 124 — three jobs at once in that run. A failed or timed-out installation now
switches to Ubuntu's public archive and tries once more, as the update step
already did.
@huichen
huichen merged commit 54e409e into main Oct 22, 2026
35 checks passed
@huichen
huichen deleted the pr/huichen branch October 22, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant