{"record":{"id":"c4c7c34d01847671","repo":"can1357/oh-my-pi","slug":"unknown-mouse-action-action","errorCode":null,"errorMessage":"unknown mouse action ${action}","messagePattern":"unknown mouse action (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tui/src/debug-server.ts","lineNumber":205,"sourceCode":"\tswitch (action) {\n\t\tcase \"click\":\n\t\t\treturn at(0) + at(0, true);\n\t\tcase \"right-click\":\n\t\t\treturn at(2) + at(2, true);\n\t\tcase \"middle-click\":\n\t\t\treturn at(1) + at(1, true);\n\t\tcase \"move\":\n\t\t\treturn at(35);\n\t\tcase \"drag\":\n\t\t\treturn at(32);\n\t\tcase \"release\":\n\t\t\treturn at(0, true);\n\t\tcase \"wheel-up\":\n\t\t\treturn at(64);\n\t\tcase \"wheel-down\":\n\t\t\treturn at(65);\n\t\tdefault:\n\t\t\tthrow new Error(`unknown mouse action ${action}`);\n\t}\n}\n\n/** NDJSON debug and input server enabled by the `OMP_TUI_DEBUG` socket path. */\nexport class TuiDebugServer {\n\treadonly #tui: TUI;\n\treadonly #path: string;\n\t#server: Server | undefined;\n\t#sockets = new Set<Socket>();\n\n\tconstructor(tui: TUI, path: string) {\n\t\tthis.#tui = tui;\n\t\tthis.#path = path;\n\t}\n\n\tstart(): void {\n\t\tif (this.#server !== undefined) return;\n\t\ttry {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/tui/src/debug-server.ts#L187-L223","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use one of the exact action strings: click, right-click, middle-click, move, drag, wheel-up, wheel-down","Omit `action` in a mouse request entirely — it defaults to \"click\"","Validate the action string against the allowed list before sending"],"exampleFix":"// before\n{ \"op\": \"mouse\", \"x\": 10, \"y\": 5, \"action\": \"scroll-up\" }\n// after\n{ \"op\": \"mouse\", \"x\": 10, \"y\": 5, \"action\": \"wheel-up\" }","handlingStrategy":"validation","validationCode":"const ACTIONS = [\"click\",\"right-click\",\"middle-click\",\"move\",\"drag\",\"wheel-up\",\"wheel-down\"];\nif (req.op === \"mouse\" && req.action !== undefined && !ACTIONS.includes(req.action))\n  throw new Error(`action must be one of: ${ACTIONS.join(\", \")}`);","typeGuard":"function isMouseAction(a: unknown): a is \"click\"|\"right-click\"|\"middle-click\"|\"move\"|\"drag\"|\"wheel-up\"|\"wheel-down\" {\n  return typeof a === \"string\" && [\"click\",\"right-click\",\"middle-click\",\"move\",\"drag\",\"wheel-up\",\"wheel-down\"].includes(a);\n}","tryCatchPattern":"try {\n  const res = await sendRequest({ op: \"mouse\", x, y, action });\n} catch (err) {\n  if (String(err.message).startsWith(\"unknown mouse action\")) {\n    action = \"click\"; // fall back to default\n  }\n}","preventionTips":["Use the TypeScript literal-union type for action so invalid values fail at compile time","Rely on the default: omit action when you mean a left click","Keep a client-side constant list mirroring the seven supported actions"],"tags":["validation","tui","debug-server"],"backgroundTag":"invalid-enum-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}