From 920bb5ae9d4324fb07ea6bf0610bd2e4cec03d7f Mon Sep 17 00:00:00 2001 From: d1rshan Date: Tue, 24 Mar 2026 17:17:50 +0530 Subject: [PATCH] fix(config): block monkey with live text stats --- .../__tests__/root/config-metadata.spec.ts | 13 ++++++++ frontend/__tests__/root/config.spec.ts | 22 +++++++++++++ frontend/src/ts/config/metadata.ts | 31 +++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/frontend/__tests__/root/config-metadata.spec.ts b/frontend/__tests__/root/config-metadata.spec.ts index d8db8f348d75..ea60ec416152 100644 --- a/frontend/__tests__/root/config-metadata.spec.ts +++ b/frontend/__tests__/root/config-metadata.spec.ts @@ -163,6 +163,19 @@ describe("ConfigMeta", () => { { value: false, given: { tapeMode: "word" } }, { value: true, given: { tapeMode: "word" }, fail: true }, ], + monkey: [ + { value: false, given: { liveSpeedStyle: "text" } }, + { value: true, given: { liveSpeedStyle: "text" }, fail: true }, + { value: true, given: { liveAccStyle: "text" }, fail: true }, + ], + liveSpeedStyle: [ + { value: "mini", given: { monkey: true } }, + { value: "text", given: { monkey: true }, fail: true }, + ], + liveAccStyle: [ + { value: "mini", given: { monkey: true } }, + { value: "text", given: { monkey: true }, fail: true }, + ], }; it.for( diff --git a/frontend/__tests__/root/config.spec.ts b/frontend/__tests__/root/config.spec.ts index d8c881e5588f..fd3572b135b2 100644 --- a/frontend/__tests__/root/config.spec.ts +++ b/frontend/__tests__/root/config.spec.ts @@ -109,6 +109,28 @@ describe("Config", () => { expect(Config.setConfig("showAllLines", true)).toBe(false); }); + it("shows a notice when monkey conflicts with live text stats", () => { + //GIVEN + replaceConfig({ liveSpeedStyle: "text", monkey: false }); + + //WHEN / THEN + expect(Config.setConfig("monkey", true)).toBe(false); + expect(notificationAddMock).toHaveBeenCalledWith( + "Monkey can't be enabled while live speed or live accuracy is set to text.", + ); + }); + + it("shows a notice when live speed text conflicts with monkey", () => { + //GIVEN + replaceConfig({ monkey: true, liveSpeedStyle: "off" }); + + //WHEN / THEN + expect(Config.setConfig("liveSpeedStyle", "text")).toBe(false); + expect(notificationAddMock).toHaveBeenCalledWith( + "Live speed can't be set to text while monkey is enabled.", + ); + }); + it("should use overrideValue", () => { //WHEN Config.setConfig("customLayoutfluid", ["3l", "ABNT2", "3l"]); diff --git a/frontend/src/ts/config/metadata.ts b/frontend/src/ts/config/metadata.ts index 4a5f62f5c2a6..42af987f528b 100644 --- a/frontend/src/ts/config/metadata.ts +++ b/frontend/src/ts/config/metadata.ts @@ -532,12 +532,30 @@ export const configMetadata: ConfigMetadataObject = { displayString: "live speed style", changeRequiresRestart: false, group: "appearance", + isBlocked: ({ value, currentConfig }) => { + if (value === "text" && currentConfig.monkey) { + showNoticeNotification( + "Live speed can't be set to text while monkey is enabled.", + ); + return true; + } + return false; + }, }, liveAccStyle: { icon: "fa-tachometer-alt", displayString: "live accuracy style", changeRequiresRestart: false, group: "appearance", + isBlocked: ({ value, currentConfig }) => { + if (value === "text" && currentConfig.monkey) { + showNoticeNotification( + "Live accuracy can't be set to text while monkey is enabled.", + ); + return true; + } + return false; + }, }, liveBurstStyle: { icon: "fa-tachometer-alt", @@ -873,6 +891,19 @@ export const configMetadata: ConfigMetadataObject = { displayString: "monkey", changeRequiresRestart: false, group: "hidden", + isBlocked: ({ value, currentConfig }) => { + if ( + value && + (currentConfig.liveSpeedStyle === "text" || + currentConfig.liveAccStyle === "text") + ) { + showNoticeNotification( + "Monkey can't be enabled while live speed or live accuracy is set to text.", + ); + return true; + } + return false; + }, }, monkeyPowerLevel: { icon: "fa-egg",