ATT-21 single instance: a later launch brings the running at-terminal forward #5

Merged
merge-queue merged 2 commits from ATT-21-single-instance into main 2026-11-18 14:00:39 -08:00
Owner

Work package: https://openproject.home.romaine.life/wp/ATT-21 (part of https://openproject.home.romaine.life/wp/ATT-19)

One at-terminal per user: launching it again, by any command line, runs nothing and brings the running window forward (AT-TERMINAL.md's "Launching it again"). Rio had no single-instance handling; every launch was a new process.

What changes

  • rioterm instance.rs: a launch claims a per-user name before anything else. Windows: a named pipe \.\pipe\at-terminal-<USERNAME>, created with FILE_FLAG_FIRST_PIPE_INSTANCE, local clients only. macOS and Linux: a Unix socket at-terminal-<uid>.sock in XDG_RUNTIME_DIR (or the temp dir); a socket nobody answers (left by an instance that ended) is taken over. The first launch serves the name on a thread; a later one sends forward and exits. On Windows the later launch first calls AllowSetForegroundWindow(ASFW_ANY), so the running one may take the foreground Windows would otherwise keep for the launcher.
  • main.rs: the claim, and a forward sends the event loop CreateWindow, which the router (one window since #3) turns into bringing the window forward.
  • A name that can't be claimed at all (the pipe or socket can't be made) logs a warning and the launch runs as the first.
  • windows-sys gains Win32_System_Pipes and Win32_Storage_FileSystem.

Tests: a_second_launch_brings_the_first_forward (two later launches, each delivered), and on Unix a_socket_left_by_an_ended_instance_is_taken_over. Run five times in a row on upstairspc, all passing.

Checked on upstairspc (Windows): fmt, clippy -D warnings, the tests. nelsonpc builds nothing. CI covers the Unix socket on Linux.

Only a real desktop shows: the window actually coming to the front over another app (ATT-23 adds the Windows foreground handling, including minimizing what's behind it).

Work package: https://openproject.home.romaine.life/wp/ATT-21 (part of https://openproject.home.romaine.life/wp/ATT-19) One at-terminal per user: launching it again, by any command line, runs nothing and brings the running window forward (AT-TERMINAL.md's "Launching it again"). Rio had no single-instance handling; every launch was a new process. **What changes** - `rioterm` `instance.rs`: a launch claims a per-user name before anything else. Windows: a named pipe `\.\pipe\at-terminal-<USERNAME>`, created with `FILE_FLAG_FIRST_PIPE_INSTANCE`, local clients only. macOS and Linux: a Unix socket `at-terminal-<uid>.sock` in `XDG_RUNTIME_DIR` (or the temp dir); a socket nobody answers (left by an instance that ended) is taken over. The first launch serves the name on a thread; a later one sends `forward` and exits. On Windows the later launch first calls `AllowSetForegroundWindow(ASFW_ANY)`, so the running one may take the foreground Windows would otherwise keep for the launcher. - `main.rs`: the claim, and a `forward` sends the event loop `CreateWindow`, which the router (one window since #3) turns into bringing the window forward. - A name that can't be claimed at all (the pipe or socket can't be made) logs a warning and the launch runs as the first. - `windows-sys` gains `Win32_System_Pipes` and `Win32_Storage_FileSystem`. **Tests**: `a_second_launch_brings_the_first_forward` (two later launches, each delivered), and on Unix `a_socket_left_by_an_ended_instance_is_taken_over`. Run five times in a row on upstairspc, all passing. **Checked** on upstairspc (Windows): fmt, clippy `-D warnings`, the tests. nelsonpc builds nothing. CI covers the Unix socket on Linux. **Only a real desktop shows**: the window actually coming to the front over another app (ATT-23 adds the Windows foreground handling, including minimizing what's behind it).
ATT-21 single instance: a later launch brings the running at-terminal forward
Some checks failed
merge-queue 2nd in line, behind #4: ATT-21 double-width and double-height rows (ESC # 3, 4, 5, 6)
Suite default / scope (pull_request) Successful in 22s
Suite default / check-rules (pull_request) Has been skipped
Suite rust / scope (pull_request) Successful in 23s
Suite rust / check-services (pull_request) Has been skipped
Suite rust / check-typos (pull_request) Has been skipped
Suite rust / check-machete (pull_request) Has been skipped
Suite rust / check-audit (pull_request) Has been skipped
Suite default / check-fetches (pull_request) Successful in 17s
Suite rust / check-format (pull_request) Successful in 32s
Suite default / reused-checks (pull_request) Successful in 20s
Suite rust / check-test-linux (pull_request) Successful in 3m3s
Suite rust / check-test-windows (pull_request) Has been cancelled
Suite rust / reused-checks (pull_request) Has been cancelled
189ba26137
Merge branch 'main' into ATT-21-single-instance
All checks were successful
Suite default / scope (pull_request) Successful in 16s
Suite default / check-rules (pull_request) Has been skipped
Suite rust / scope (pull_request) Successful in 15s
Suite rust / check-services (pull_request) Has been skipped
Suite rust / check-typos (pull_request) Has been skipped
Suite rust / check-machete (pull_request) Has been skipped
Suite rust / check-audit (pull_request) Has been skipped
Suite default / reused-checks (pull_request) Successful in 7s
Suite default / check-fetches (pull_request) Has been skipped
Suite rust / check-format (pull_request) Successful in 10s
Suite rust / check-test-linux (pull_request) Successful in 1m39s
Suite rust / check-test-windows (pull_request) Successful in 4m32s
Suite rust / reused-checks (pull_request) Successful in 14s
merge-queue landed on main
8cd7d3209a
merge-queue deleted branch ATT-21-single-instance 2026-11-18 14:00:39 -08:00
Sign in to join this conversation.
No reviewers
No labels
queue
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/at-terminal!5
No description provided.