From d0fe5b86fea110c443ff0d1f8e59f5c1b0a77468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 14 Jul 2026 16:18:34 +0200 Subject: [PATCH 1/3] fix: expand macro field limits to match config data types Align mouse move/scroll and delay macro editor limits with Int16 and UInt16 serialization bounds, and clamp out-of-range coordinate input. Co-authored-by: Cursor --- .../src/config-serializer/assert.ts | 24 +++++++---- .../tab/delay/macro-delay.component.html | 2 +- .../tab/delay/macro-delay.component.ts | 9 +++-- .../tab/mouse/macro-mouse.component.html | 40 +++++++++---------- .../tab/mouse/macro-mouse.component.ts | 19 ++++++++- 5 files changed, 62 insertions(+), 32 deletions(-) diff --git a/packages/uhk-common/src/config-serializer/assert.ts b/packages/uhk-common/src/config-serializer/assert.ts index 75482050758..da685b2689f 100644 --- a/packages/uhk-common/src/config-serializer/assert.ts +++ b/packages/uhk-common/src/config-serializer/assert.ts @@ -1,31 +1,41 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +export const INT8_MIN = -0x80; +export const INT8_MAX = 0x7F; +export const INT16_MIN = -0x8000; +export const INT16_MAX = 0x7FFF; +export const INT32_MIN = -0x80000000; +export const INT32_MAX = 0x7FFFFFFF; +export const UINT8_MAX = 0xFF; +export const UINT16_MAX = 0xFFFF; +export const UINT32_MAX = 0xFFFFFFFF; + export function assertUInt8(target: any, key: string) { - return assertInteger(target, key, 0, 0xFF); + return assertInteger(target, key, 0, UINT8_MAX); } export function assertInt8(target: any, key: string) { - return assertInteger(target, key, -0x80, 0x7F); + return assertInteger(target, key, INT8_MIN, INT8_MAX); } export function assertUInt16(target: any, key: string) { - return assertInteger(target, key, 0, 0xFFFF); + return assertInteger(target, key, 0, UINT16_MAX); } export function assertInt16(target: any, key: string) { - return assertInteger(target, key, -0x8000, 0x7FFF); + return assertInteger(target, key, INT16_MIN, INT16_MAX); } export function assertUInt32(target: any, key: string) { - return assertInteger(target, key, 0, 0xFFFFFFFF); + return assertInteger(target, key, 0, UINT32_MAX); } export function assertInt32(target: any, key: string) { - return assertInteger(target, key, -0x80000000, 0x7FFFFFFF); + return assertInteger(target, key, INT32_MIN, INT32_MAX); } export function assertFloat(target: any, key: string) { - return assertInteger(target, key, -0x80000000, 0x7FFFFFFF); + return assertInteger(target, key, INT32_MIN, INT32_MAX); } export function assertCompactLength(target: any, key: string) { diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html index f9ba3799f39..b2433917945 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html @@ -10,7 +10,7 @@

Delay

Move mouse pointer pixels + [ngModel]="macroAction['x']" + (ngModelChange)="setCoordinate('x', $event)" + [min]="INT16_MIN" + [max]="INT16_MAX" + maxlength="6"> pixels
pixels + [ngModel]="macroAction['y']" + (ngModelChange)="setCoordinate('y', $event)" + [min]="INT16_MIN" + [max]="INT16_MAX" + maxlength="6"> pixels
@@ -69,22 +69,22 @@

Scroll with mouse

pixels + [ngModel]="macroAction['x']" + (ngModelChange)="setCoordinate('x', $event)" + [min]="INT16_MIN" + [max]="INT16_MAX" + maxlength="6"> pixels
pixels + [ngModel]="macroAction['y']" + (ngModelChange)="setCoordinate('y', $event)" + [min]="INT16_MIN" + [max]="INT16_MAX" + maxlength="6"> pixels
diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/mouse/macro-mouse.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/mouse/macro-mouse.component.ts index 96e7fac2ea4..f3151a36226 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/mouse/macro-mouse.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/mouse/macro-mouse.component.ts @@ -2,6 +2,8 @@ import { Component, Input, OnChanges, OnInit } from '@angular/core'; import { faArrowsAlt, faArrowsAltV, faHandPaper, faHandRock, faMousePointer } from '@fortawesome/free-solid-svg-icons'; import { + INT16_MAX, + INT16_MIN, MacroMouseSubAction, MouseButtons, MouseButtonMacroAction, @@ -33,6 +35,8 @@ enum TabName { export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit, OnChanges { @Input() macroAction: MouseMacroAction; + INT16_MAX = INT16_MAX; + INT16_MIN = INT16_MIN; MouseButtons = MouseButtons; TabName = TabName; activeTab: TabName; @@ -114,6 +118,17 @@ export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit } } + setCoordinate(axis: 'x' | 'y', value: number | string): void { + const numericValue = Number(value); + if (Number.isNaN(numericValue)) { + return; + } + + const action = this.macroAction as MoveMouseMacroAction | ScrollMouseMacroAction; + action[axis] = Math.min(Math.max(Math.round(numericValue), INT16_MIN), INT16_MAX); + this.validate(); + } + getTabName(action: MouseMacroAction): TabName { if (action instanceof MouseButtonMacroAction) { if (!action.action || action.isOnlyClickAction()) { @@ -137,7 +152,9 @@ export class MacroMouseTabComponent extends MacroBaseComponent implements OnInit case ScrollMouseMacroAction: { const { x, y } = this.macroAction as MoveMouseMacroAction; return x !== undefined && x !== null && y !== undefined && y !== null && - (x !== 0 || y !== 0) && x < 10000 && x > -10000 && y < 10000 && y > -10000; + (x !== 0 || y !== 0) && + x >= INT16_MIN && x <= INT16_MAX && + y >= INT16_MIN && y <= INT16_MAX; } case MouseButtonMacroAction: { From 2f102e3c5e0dbf9b13848e449e9fa3814c86459e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiss=20R=C3=B3bert?= Date: Tue, 14 Jul 2026 20:49:51 +0200 Subject: [PATCH 2/3] fix: use valueAsNumber --- .../macro/action-editor/tab/delay/macro-delay.component.html | 2 +- .../macro/action-editor/tab/delay/macro-delay.component.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html index b2433917945..43f727bd2b8 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.html @@ -15,7 +15,7 @@

Delay

placeholder="Delay amount" class="form-control" [ngModel]="delay" - (ngModelChange)="setDelay(macroDelayInput.value)"> + (ngModelChange)="setDelay(macroDelayInput.valueAsNumber)"> seconds diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts index 367fde2f119..7c2b7d52349 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts @@ -46,6 +46,10 @@ export class MacroDelayTabComponent extends MacroBaseComponent implements OnInit } setDelay(value: number): void { + if (Number.isNaN(value)) { + return; + } + const delayMs = Math.min(Math.max(Math.round(value * 1000), 0), UINT16_MAX); this._delay = delayMs / 1000; this.macroAction.delay = delayMs; From 7d7632d6b281e2262813f02465b2826dedff8420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiss=20R=C3=B3bert?= Date: Tue, 14 Jul 2026 21:13:03 +0200 Subject: [PATCH 3/3] fix: delay macro validation --- .../macro/action-editor/tab/delay/macro-delay.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts index 7c2b7d52349..e3f110ec3c4 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/delay/macro-delay.component.ts @@ -51,11 +51,10 @@ export class MacroDelayTabComponent extends MacroBaseComponent implements OnInit } const delayMs = Math.min(Math.max(Math.round(value * 1000), 0), UINT16_MAX); - this._delay = delayMs / 1000; this.macroAction.delay = delayMs; - this.validate(); + this.delay = delayMs / 1000; } - isMacroValid = () => this.macroAction.delay !== 0; + isMacroValid = () => this.macroAction.delay > 0 && this.macroAction.delay <= UINT16_MAX; }