can1357/oh-my-pi · error

unknown mouse action ${action}

Error message

unknown mouse action ${action}

What it means

mouseSequence() encodes xterm-style SGR mouse escape sequences for a fixed set of action names. When the action string is not one of click, right-click, middle-click, move, drag, wheel-up, or wheel-down, the default branch throws this error. It is a programming/input-validation guard in the TUI debug server's mouse dispatch path.

Source

Thrown at packages/tui/src/debug-server.ts:205

	switch (action) {
		case "click":
			return at(0) + at(0, true);
		case "right-click":
			return at(2) + at(2, true);
		case "middle-click":
			return at(1) + at(1, true);
		case "move":
			return at(35);
		case "drag":
			return at(32);
		case "release":
			return at(0, true);
		case "wheel-up":
			return at(64);
		case "wheel-down":
			return at(65);
		default:
			throw new Error(`unknown mouse action ${action}`);
	}
}

/** NDJSON debug and input server enabled by the `OMP_TUI_DEBUG` socket path. */
export class TuiDebugServer {
	readonly #tui: TUI;
	readonly #path: string;
	#server: Server | undefined;
	#sockets = new Set<Socket>();

	constructor(tui: TUI, path: string) {
		this.#tui = tui;
		this.#path = path;
	}

	start(): void {
		if (this.#server !== undefined) return;
		try {

View on GitHub (pinned to 9690622007)

Solutions

  1. Use one of the exact action strings: click, right-click, middle-click, move, drag, wheel-up, wheel-down
  2. Omit `action` in a mouse request entirely — it defaults to "click"
  3. Validate the action string against the allowed list before sending

Example fix

// before
{ "op": "mouse", "x": 10, "y": 5, "action": "scroll-up" }
// after
{ "op": "mouse", "x": 10, "y": 5, "action": "wheel-up" }
Defensive patterns

Strategy: validation

Validate before calling

const ACTIONS = ["click","right-click","middle-click","move","drag","wheel-up","wheel-down"];
if (req.op === "mouse" && req.action !== undefined && !ACTIONS.includes(req.action))
  throw new Error(`action must be one of: ${ACTIONS.join(", ")}`);

Type guard

function isMouseAction(a: unknown): a is "click"|"right-click"|"middle-click"|"move"|"drag"|"wheel-up"|"wheel-down" {
  return typeof a === "string" && ["click","right-click","middle-click","move","drag","wheel-up","wheel-down"].includes(a);
}

Try / catch

try {
  const res = await sendRequest({ op: "mouse", x, y, action });
} catch (err) {
  if (String(err.message).startsWith("unknown mouse action")) {
    action = "click"; // fall back to default
  }
}

Prevention

When it happens

Trigger: Calling the debug server 'mouse' request with an `action` field that is not one of the seven supported strings (e.g. "scroll-up", "Move", "mousedown"), or calling mouseSequence() directly with a misspelled action.

Common situations: Scripting the OMP_TUI_DEBUG NDJSON socket and guessing action names; typos like "wheelup" or camelCase variants; clients ported from a different tool with different mouse action vocabulary.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/c4c7c34d01847671. Report an issue: GitHub.