Skip to content

Feat/windows/terminal sessions - #38

Closed
milestone-17 wants to merge 10 commits into
1lck:integration/windowsfrom
milestone-17:feat/windows/terminal-sessions
Closed

milestone-17 wants to merge 10 commits into
1lck:integration/windowsfrom
milestone-17:feat/windows/terminal-sessions

Conversation

@milestone-17

Copy link
Copy Markdown
Contributor

test

…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.
@milestone-17
milestone-17 requested a review from 1lck as a code owner August 10, 2026 07:25
@1lck

1lck commented Aug 10, 2026

Copy link
Copy Markdown
Owner

在跑了

milestone-17 and others added 8 commits August 10, 2026 15:59
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 added a commit that referenced this pull request Nov 14, 2026
* feat(plugins): 同一语言只由一个已启用插件提供语言服务器

启用插件或确认安装后,其他已启用、且为同一语言声明语言服务器的插件会被自动
停用:Core(Lithe-core-rust#39)在 plugins.installed.lifecycle 里返回
displacePlugin,宿主记为停用、停掉它的语言服务器和后端,提示用户停用了谁、
为什么,并为已打开的共享语言文档启动新插件的服务器。

- pluginmanager 规划时为每个已安装版本读出清单 languageServers,Apply 返回
  Outcome(Changed、Displaced),新增 Enable。
- pluginservice.StopDisplaced 停止被顶替插件的程序。
- 工作台 plugin_displace.go:读名称、摘除服务器、后台停止、提示和重启服务器。
- 新文案 desktop.marketplace.languageServerDisplaced(中英)。
- Core 固定修订升到 a320d16(#38、#39)。
- 功能矩阵与 Agent Note 同步。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(plugins): 工作台安装第二个同语言插件时停用第一个并提示

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(plugins): 轻量 Java 插件改名为 Java Support Lite

Agent Note 与功能矩阵的验收步骤改用新名称,记录 Store 收录状态(Lithe-store#62 已合并,#63 等本规则发布)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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