Lutra/crates/engine/tests
danny 20d1d28c32 M3.5: pending outcomes for commands that wait for the language server
Step 1 of M3.5: the shared mechanism. M3.4 and M3.5 build on it.

- Engine: `Outcome.pending: Option<Pending>`. `Pending::new(rx, timeout,
  finish)`; `Pending::wait()` is called without the engine lock and
  returns at the answer, a dropped sender or the deadline (timeout + 1 s).
  `Engine::resolve(answered)` then runs `finish(state, reply)` inside the
  guard, under the lock. `run_waiting(lock, cmd, params, publish)` does
  all three steps for hosts.
- Hosts: `Host::run`, `testkit::EngineBackend` and the control test
  backend use `run_waiting`.
- New IPC `engine_execute_waiting` (`#[tauri::command(async)]`, off the
  main thread) with `runWaiting()` in `ui/src/ipc.ts`. Only `lsp.*`
  requests use it.

Ordering guarantee:
- `engine_execute` stays synchronous on the main thread, so ordinary
  commands (`buffer.edit`) still run in call order.
- The order towards the server is fixed under the engine lock:
  `buffer.edit` queues its didChange on the session's FIFO queue before
  it returns, and `lsp::submit` queues the request on the same queue.
  A request therefore sees every edit whose `buffer.edit` returned
  first, and the UI awaits the sync's `idle()` before sending one.

Failures:
- A stall is caught by the request timeout, with the deadline as
  backstop.
- On restart, close, quit or crash the request is dropped or resolved
  as stopped, so the waiter gets an error, never a hang.

Tests: `crates/engine/tests/pending.rs` (answer, lock free while
waiting, dropped sender, deadline, resolve, lsp.restart while a
request is pending) and Vitest for `runWaiting`. Gate: 13 steps,
321 s, Vitest 443 + 1 skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 06:36:20 +02:00
..
goto.rs M2.6: go-to popup for files, classes and symbols 2026-10-17 17:35:50 +02:00
lsp.rs M3.3: engine wiring for Phpactor and diagnostics 2026-10-21 18:58:32 +02:00
pending.rs M3.5: pending outcomes for commands that wait for the language server 2026-10-22 06:36:20 +02:00
recovery.rs M1.15: one modal at a time, restore dialog follows outside restores 2026-10-16 21:49:38 +02:00
search.rs M2.3: find in files backend 2026-10-16 22:04:28 +02:00
settings.rs M3.10: autosave and flushDirty 2026-10-20 21:01:12 +02:00
syntax.proptest-regressions M2.7: Structure tool window and syntax.outline 2026-10-17 17:04:12 +02:00
syntax.rs M2.7: Structure tool window and syntax.outline 2026-10-17 17:04:12 +02:00
terminal.rs M3.6: integrated terminal with PTY sessions and xterm.js sub-tabs 2026-10-20 21:10:37 +02:00
theme.rs M1.10: light theme, live theme switching, editor tokens 2026-10-16 15:49:23 +02:00
ui_commands.rs M1.8: command palette, global keymap, UI commands 2026-10-16 16:59:43 +02:00
workspace.rs M3.10: autosave and flushDirty 2026-10-20 21:01:12 +02:00