Skip to content

fix(nsh): route page-selection Copy at platform boundary and keep RichEditor keys static - #6731

Merged
M4n5ter merged 1 commit into
rust-previewfrom
fix/rich-editor-copy-page-selection
Nov 10, 2026
Merged

M4n5ter merged 1 commit into
rust-previewfrom
fix/rich-editor-copy-page-selection

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 10, 2026

Copy link
Copy Markdown
Member

Summary

Restore rust-preview CI after #6726 while preserving its page-selection copy behavior across platforms:

  1. Keep RichEditor's key table static across selection changes (nsh-base):

    • fix(nsh): leave Copy to the page when the focused editor selects nothing #6726 gated mod+c / mod+x in RichEditor's key-table effect on !rv.session.state().selection().empty().
    • Because MountItem::Keymap on the platform UI thread is an asynchronous snapshot of the engine thread's state, any input burst that selects and copies back-to-back (Mod+A followed immediately by Mod+C, or Paste + Mod+A + Mod+C before an intermediate frame round-trip) evaluated Mod+C against the pre-selection Keymap, dropping the copy on macOS/Windows and triggering terminal interrupt/exit on TUI. Re-running the key-table effect on every selection transition also tore down and reallocated all ~500 ViewKey bindings, invalidating in-flight KeyCommand IDs, and bypassed ComposerBehavior::handle_key_down's editor-internal ctrl+c fallback (clearDraft / interrupt) when ComposerInput had an empty selection and no page selection existed.
    • Restore static mod+c / mod+x registration on RichEditor so FIFO engine execution handles Select All -> Copy bursts and ComposerInput's ctrl+c fallback deterministically.
  2. Route Copy and Escape to an active page output selection at the platform boundary (nsh-platform-macos, nsh-platform-windows, nsh-platform-tui):

    • The platform UI thread synchronously owns the surface's output selection (text::has_selection / selectable_view::has_selection / Selection::key_while_editing).
    • When an editor holds focus without a native field selection of its own while the surface still has selected output (for example after programmatic editor.focus()), Copy (Cmd+C / Ctrl+C / Ctrl+Insert / Alt+W as appropriate to each platform) copies the surface's selected output, Escape clears the output selection, and any other non-modifier key clears the stale output selection so subsequent Mod+A -> Mod+C copies the editor's own content.
    • Retain fix(nsh): leave Copy to the page when the focused editor selects nothing #6726's macOS NSTextView::copy:, menu validation (validateUserInterfaceItem:), and NshView keyboard_surface() fallback, and extend TerminalSurface dispatch_terminal_key with the same empty-range surface-copy fallback.

Refs #6726

Verification

  • cargo nextest run --manifest-path third-party/nsh/Cargo.toml -p nsh-base --test base rich_editor::marks_clipboard_history — passed (copy_with_nothing_selected_preserves_existing_clipboard + copy_writes_markdown).
  • cargo nextest run --manifest-path third-party/nsh/Cargo.toml -p nsh-platform-tui --test tui focused_rich_editor_yields_copy_to_page_selection_and_keeps_select_all_copy_burst — passed (verifies both copying active page output while RichEditor holds focus and back-to-back Ctrl+A -> Ctrl+C burst copying RichEditor content).
  • cargo nextest run -p maka-workbench --lib — passed (verifies ComposerInput ctrl+c clearDraft / copy fallback behavior).
  • cargo fmt --manifest-path third-party/nsh/Cargo.toml --all -- --check, node scripts/ci.mjs check format, node scripts/ci.mjs check licenses, node scripts/ci.mjs check tooling-tests (265/265 passed).
  • Not run locally on Linux: full maka-cli --test integration binary link (cancelled locally due to WSL debug-link memory pressure; covered by root-tests), nsh-platform-macos AppKit host tests (including new focused_rich_editor_yields_copy_to_selected_output), and nsh-platform-windows unit/desktop tests — covered by root-tests, native-macos, and native-windows CI jobs on this PR.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Antigravity diagnosed the post-#6726 CI failures across Linux, macOS, and Windows and authored the platform-boundary selection copy routing, static RichEditor key-table restoration, and regression tests (Generated-by: Antigravity).

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

…hEditor keys static

Keep RichEditor's Mod+C and Mod+X bindings static across selection transitions so back-to-back Select All -> Copy bursts and ComposerInput's editor-internal Ctrl+C fallback run deterministically without key-table churn, while routing Copy and Escape to an active surface output selection at the platform boundary on macOS, Windows, and TUI when the focused editor has no native selection of its own.

Refs #6726

Generated-by: Antigravity
@M4n5ter
M4n5ter merged commit 9294ba7 into rust-preview Nov 10, 2026
7 of 10 checks passed
@M4n5ter
M4n5ter deleted the fix/rich-editor-copy-page-selection branch November 10, 2026 04:20
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.

1 participant