Repository navigation
Feat/windows/terminal sessions - #51
Merged
1lck merged 12 commits intoAug 11, 2026
Merged
Conversation
…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>
1lck
approved these changes
Aug 11, 2026
1lck
left a comment
Owner
There was a problem hiding this comment.
Approved for merge per repository owner direction; Windows CI failure is accepted for this merge.
1lck
approved these changes
Aug 11, 2026
11 of 14 tasks
This was referenced Nov 15, 2026
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 15, 2026
9 of 15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.