fix(focus-core): a record for the workspace the window already shows focuses its saved pane (QA v2.2.2 bug 1, step A)

Merged
LA
3d ago
+142-4

Summary

Step A of the two-step FFI move for row 2 (lead decision, STATUS 5388). The Swift half stays in #31852 and lands as step B after the repin.

QA v2.2.2 bug 1: after Cmd-Q with a browser tab focused in the pane beside Home, and a relaunch, the keys typed go into Home's Chief message box. The launch window shows the home workspace (Home's page first, then the pane with the terminal and the selected browser tab) before it adopts the saved window record. The record's focused pane comes as restoredPane for that shown workspace, and the cmux-focus-core rule dropped it (reducer.rs, it remembered the pane only for a workspace the window does not show). Home kept the focus.

After this change, in cmux-focus-core: a restoredPane for the workspace the window already shows takes the focus while no user intent happened in the window (generation 0); the target goes back to the content (also from a programmatic address-bar move). It moves the pane and re-applies the responder, like a programmatic focusPane. A person's click or key before the record keeps their choice. A view that took the keyboard by itself (a programmatic responder report) does not.

Ports 77c95946de09 from cp/dogfood-v2-2-12-opt. The dogfood line put this rule in the Swift app, because its app links a pinned FFI. Here it is in the Rust crate that owns the rule (plans/cmux-next/layer-ownership.md).

There is no Swift change in this PR. The app keeps the old rule until the bot publishes the app-ffi release and the repin PR lands. Then #31852 lands its Swift half: Home's unasked keyboard gate (47d6a3f31d97) and the 4 RestoredFocusTests, with their Mac suites.

Check the app FFI pin: expected, step A of a two-step FFI move (continue-on-error).

Testing

Focused command (fleet, Linux): scripts/ci/cmux-tui-rust-check.sh test restored_pane (cmux-focus-core/tests/restored_pane.rs). The same cases, plus one more, are in cmux-layout-reducer-ffi/tests/focus_rules.rs, which cmux-tui.yml runs in its own workspace.

  • Red at 6810b9fde47 (feat + tests only): step 0e4bbb3e8b93a6daa77af684 FAILED as expected: restored_pane_for_the_shown_workspace_focuses_its_saved_pane panics at restored_pane.rs:41 (Home keeps the focus); the guard restored_pane_never_overrides_the_persons_choice passes
  • Green at head: step 8058a64c3f48325ccdb069b2 PASSED, 2 of 2
  • cmux-focus-core all tests, clippy, fmt at head: fmt 2f07b15e2cf786c6999fb597 passed. clippy e8134664cd6428600d717549 is red on a BASE finding, not this PR: too_many_arguments at cmux-tui-core/src/output_store/snapshot.rs:537 from #31931 (e3c495d3baf2); fix PR follows. The wider focus test filter (132 tests, every focus-core and focus-related test of the workspace) passed: step eba9a30fbea09e8f9ffde51c. Base-red fix for clippy: #32092 (ready-to-land)

The same red/green has already passed on the #31852 branch: red e3e9ae38fc72f7510047dc53, green f16e672983292f101e8385a0.

Observed / Not run

Observed: the fleet steps above. Not run: macOS Rust tests, the app with a new FFI (it needs the repin, step B), the dogfood journey for QA v2.2.2 bug 1.

Changelog

none (the app behaviour changes with the step B PR, #31852)

Proof

No capture: Rust rule only; no app change until the repin.