Previously, v2SurfaceSendText, v2SurfaceSendKey, v2SurfaceClearHistory, and
v2SurfaceReadText would silently fall back to ws.focusedPanelId when a caller
supplied a surface_id that could not be resolved (e.g. a stale ref or an ordinal
whose mapping had not yet been registered). This caused two distinct bugs:
- #2042: Commands like `cmux send --surface surface:9999` would succeed (exit 0)
and deliver input to the focused pane instead of returning an error, making
automation that targets specific surfaces unreliable.
- #2045: When the fallback landed on a browser panel, the subsequent
ws.terminalPanel(for:) check failed and returned "Surface is not a terminal",
making valid terminal surfaces appear broken when addressed by ref.
The fix adds an explicit check: if params["surface_id"] is present but
v2UUID() returns nil (resolution failure), we immediately return a not_found
error instead of falling back to the focused pane. When surface_id is absent,
the existing focused-pane fallback is preserved for backward compatibility.
Fixes#2042, Fixes#2045
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>