Skip to content

Feat/windows/terminal sessions - #51

Merged
1lck merged 12 commits into
1lck:integration/windowsfrom
milestone-17:feat/windows/terminal-sessions
Aug 11, 2026
Merged

1lck merged 12 commits into
1lck:integration/windowsfrom
milestone-17:feat/windows/terminal-sessions

Conversation

@milestone-17

Copy link
Copy Markdown
Contributor

No description provided.

milestone-17 and others added 12 commits August 10, 2026 13:25
…le, Qt panel

Implement issue #31 ([Windows][W3] 多会话终端系统), phase 4 of the Windows
development plan: turn the single hardcoded ConPTY session owned by
WorkbenchWindow into a multi-session terminal feature model that Qt renders.
The terminal stays off the rust/lithe-core JSON protocol (windows/-local),
per the application boundary contract.

Feature model + port (pure C++, no Qt/Win32 — verifiable off-Windows):
- adapters/ports.h: TerminalTransport gains setLifecycleHandler carrying the
  owning operationID, so a restart can drop stale callbacks (mirrors
  ProcessSession's lifecycle shape).
- adapters/win32_terminal_transport: emit Starting/Running/Failed/Finished
  through the existing once-only exit latch (exactly one terminal event per
  launch); Job-Object teardown (TerminateJobObject / KILL_ON_JOB_CLOSE) is
  unchanged, so a descendant cannot outlive a stop.
- app/services/terminal_{model,session}: session collection + current id + a
  terminal epoch (bumped on closeAll/shutdown to drop in-flight callbacks);
  each session owns its ConPTY transport + bounded TerminalBuffer + a launch
  generation guard; scoped new/select/close/switch and Clear/Interrupt (\x03)/
  Restart; closeAll() for workspace switch, shutdown() for app exit.

Qt UI (offscreen-tested):
- qt/terminal_{panel,view}: tab bar with new/close, shell selector, and a
  Clear/Interrupt/Restart toolbar; renders the bounded TerminalBuffer; marshals
  model callbacks onto the UI thread via queued connections.
- qt/workbench_window: owns a TerminalModel + TerminalPanel instead of a raw
  transport; openWorkspaceRoot closeAll()'s the prior workspace's sessions;
  destructor detaches the panel then shutdown()s the model (avoids touching a
  freed model from the panel dtor, since Qt child deletion runs after member
  destruction).

Tests + build:
- tests/fake_terminal_transport.h + terminal_model_test.cpp (11 cases, runs
  with plain g++; covers isolation, lifecycle, restart+stale-drop, duplicate
  stop, closeAll, bounded heavy output) and terminal_panel_test.cpp (8 cases,
  Qt offscreen; tabs, scoping, switch/close, restart).
- CMakeLists.txt: register terminal sources in lithe_windows_app (+ link
  lithe_windows_algorithms); add platform-independent
  lithe_windows_terminal_model_tests and offscreen
  lithe_windows_terminal_panel_tests; register Qt panel/view sources in
  lithe_windows_qt.

Verified locally: model test (11/11) and panel test (8/8) compile and pass;
scripts/verify-windows-boundaries.ps1 passes.
Still gated to Windows CI (MSVC+Qt+Rust): the workbench_window.cpp integration,
the full CMake build, and the real-ConPTY multi-session teardown test.
The terminal transport test ran `cmd /d /k ver`, but commandLine() quotes each
argument, producing `cmd "/d" "/k" "ver"`. cmd mishandles the quoted switch and
command ("ver" treated as an unknown program; the quoted /k sometimes not
recognized), nondeterministically exiting on a headless CI ConPTY and failing
`assert(isRunning())` (test #19, exit 0xc0000409) — see the Windows CI failure
on PR #38.

Replace it with `ping -n 31 127.0.0.1` (resolved via %SystemRoot%\System32): a
deterministic ~30s process with no quoting pitfalls and no visible window, so
the transport's start / isRunning / descendants / stop checks stay stable on CI.
Add terminal_integration_test.cpp covering the issue #31 integration scenarios
that the fake-transport unit tests cannot: two real cmd sessions running
concurrently via the TerminalModel, per-session IO isolation, switching,
interrupt (Ctrl+C) of a foreground ping, restart, and whole-process-tree
teardown on closeAll() (verified empty via the CreateToolhelp32Snapshot
descendant walk).

Compiles the model + session sources directly (no core/Rust dependency) and
links the Win32 adapters + algorithms; the body is an empty main off-Windows.
Registered as lithe_windows_terminal_integration_tests, alongside the transport
test.

Task 6.1 is intentionally left unchecked until Windows CI confirms this green.
- terminal_panel: Clear/Interrupt/Restart are now icon-only QToolButtons
  (QStyle standard pixmaps SP_DialogResetButton / SP_BrowserStop /
  SP_BrowserReload) with tooltips and auto-raise, matching issue #31's
  "standard icon buttons" requirement. New/Close stay text buttons.
- workbench_window: availableShells() detects installed Windows shells
  (cmd.exe, powershell.exe, pwsh.exe under %SystemRoot% / %ProgramFiles%)
  via QFile::exists plus the configured shell, so the menu only offers
  shells that are actually present.

Panel change verified locally (g++13 + Qt offscreen, 8/8 panel tests pass);
workbench change is MSVC/CI-verified (pure Qt).
…on test

state_ was written by the transport worker thread (under mutex_) but read by
the UI/test thread via state() without the lock — a data race. On the Windows
CI ConPTY integration test this surfaced as the Running transition never being
observed: the session stayed non-Running for the full 15s wait even though the
cmd child was alive (banner + prompt visible), failing
assert(state() == Running).

Make state_ std::atomic<State> so the cross-thread read is defined behaviour
and the Running transition is reliably observable. The write paths
(launch / onLifecycle / stop) keep using the mutex for the generation check
and compound updates; only the state_ slot itself is now atomic.

Also add diagnostics to terminal_integration_test: if a session does not reach
Running in time, print its state, the descendant-process count, and a buffer
snippet, so the next CI run pinpoints the cause if the atomic fix is not the
whole story.

Local: model test 11/11 and panel test 8/8 still pass (g++ + Qt offscreen).
Local openspec planning for the terminal work:
- windows-terminal-sessions: the in-progress multi-session terminal change.
- windows-terminal-emulator: proposed next change (real VT/ANSI emulator +
  direct input), to be implemented on an MSVC+Qt+Rust machine.
- Multi-session terminal with tabs, per-session state, lifecycle events,
  shell selection, scoped Clear/Interrupt/Restart, and reliable process-tree
  teardown on close-project and app-exit.
- ANSI/VT terminal emulator with surface rendering, direct keyboard input,
  PTY geometry tracking, and off-Windows testability.
- Suppress git console window flash when running from the GUI build by
  setting CREATE_NO_WINDOW on git subprocesses.
- Archive completed openspec changes and synchronize main specs.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@milestone-17
milestone-17 requested a review from 1lck as a code owner August 11, 2026 02:04

@1lck 1lck left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Approved for merge per repository owner direction; Windows CI failure is accepted for this merge.

@1lck
1lck merged commit bf78040 into 1lck:integration/windows Aug 11, 2026
1 of 2 checks passed
xiaoyumuxi added a commit that referenced this pull request Nov 15, 2026
Lithe-core-rust #52 允许工具定义的版本探针以子命令开头(go version),
Go 插件据此在新建项目里默认读取本机 Go 版本、提供 GOROOT 选择。固定版本
同时带上 #48–#51。
xiaoyumuxi added a commit that referenced this pull request Nov 15, 2026
Lithe-core-rust #52 允许工具定义的版本探针以子命令开头(go version),
Go 插件据此在新建项目里默认读取本机 Go 版本、提供 GOROOT 选择。固定版本
同时带上 #48–#51。
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.

2 participants