Skip to content

Add optional long and mega breaks to Break Handler V2 - #1833

Open
MuffinKid23 wants to merge 1 commit into
chsami:developmentfrom
MuffinKid23:breakhandler-v2-long-break
Open

Add optional long and mega breaks to Break Handler V2#1833
MuffinKid23 wants to merge 1 commit into
chsami:developmentfrom
MuffinKid23:breakhandler-v2-long-break

Conversation

@MuffinKid23

@MuffinKid23 MuffinKid23 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • add optional long-break and mega-break timing configuration to Break Handler V2
  • keep normal breaks independent from pending long/mega timers
  • merge due long/mega timers into an already-active break instead of starting competing break cycles
  • prioritize mega breaks when long and mega timers coincide
  • show runtime, break count, long-break countdown, mega-break countdown, and active break type in the overlay

Test

  • ./gradlew.bat :client:compileJava -x test

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a358f04e-20a3-432c-bc6a-2b63e51449af

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

BreakHandler V2 adds configurable long breaks with randomized intervals and durations. The script tracks pending and active long-break state, merges due long breaks into active breaks, preserves timers across normal breaks, and resets them during lifecycle transitions. It exposes runtime metrics, break counts, countdowns, and break type. The overlay displays these values and identifies long breaks.

Possibly related PRs

  • chsami/Microbot#1622: Modifies the same break-handler configuration, script, and overlay areas.
  • chsami/Microbot#1624: Extends the same BreakHandler V2 functionality across its configuration, scheduling, and overlay code.
  • chsami/Microbot#1640: Modifies the same break-handler classes for related scheduling behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the optional long-break feature, which is the main change summarized for Break Handler V2.
Description check ✅ Passed The description is related to the break-timing configuration, scheduling behavior, overlay updates, and validation command.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Config.java`:
- Around line 87-101: Update the default values in BreakHandlerV2Config’s
minLongBreakInterval() and maxLongBreakInterval() so the default long-break
window starts after the normal playtime range, preventing long breaks from
preempting normal breaks; leave the configured range constraints unchanged.

In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Script.java`:
- Around line 74-75: Update the currentBreakIsLong field in BreakHandlerV2Script
to provide thread-safe visibility between the script/scheduler writer and
BreakHandlerV2Overlay.render’s isCurrentBreakLong() reader, preferably by
declaring it volatile or consistently synchronizing both access paths.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c21c6005-ab3c-47a5-bf1d-3eca64c65a7a

📥 Commits

Reviewing files that changed from the base of the PR and between 463c2c7 and e540455.

📒 Files selected for processing (3)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Config.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Overlay.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Script.java

Comment on lines +87 to +101
@Range(min = 1, max = 600)
default int minLongBreakInterval() {
return 20;
}

@ConfigItem(
keyName = "maxLongBreakInterval",
name = "Max Long Break Interval (minutes)",
description = "Maximum time to play before a long break can trigger",
position = 6,
section = breakTimingSettings
)
@Range(min = 1, max = 600)
default int maxLongBreakInterval() {
return 30;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Prevent the default long-break interval from suppressing normal breaks.

The default long-break interval is 20-30 minutes. The default normal playtime is 45-90 minutes. The scheduler creates both deadlines at the same time and handles a due long break first. After that long break, it reschedules the normal deadline. Therefore, enabling long breaks with defaults prevents a normal break from starting.

Set the default long-break interval above the normal-playtime range, or retain the normal deadline when a long break completes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Config.java`
around lines 87 - 101, Update the default values in BreakHandlerV2Config’s
minLongBreakInterval() and maxLongBreakInterval() so the default long-break
window starts after the normal playtime range, preventing long breaks from
preempting normal breaks; leave the configured range constraints unchanged.

Comment on lines +74 to +75
private boolean longBreakDue = false;
private boolean currentBreakIsLong = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate files =="
fd -a 'BreakHandlerV2(Script|Overlay)\.java$' . || true

echo "== relevant snippets =="
for f in $(fd 'BreakHandlerV2(Script|Overlay)\.java$' .); do
  echo "--- $f ($(wc -l < "$f") lines) ---"
  ast-grep outline "$f" --view compact || true
  rg -n "currentBreakIsLong|isCurrentBreakLong|nextLongBreakTime|break|longBreak|synchronized|volatile|BlockingEventManager|Thread|new Thread|schedule" "$f" -C 3
done

echo "== search scheduler writes/reads =="
rg -n "currentBreakIsLong|isCurrentBreakLong|nextLongBreakTime" runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2 -C 2

Repository: chsami/Microbot

Length of output: 50371


Publish currentBreakIsLong to the overlay thread.

BreakHandlerV2Script writes currentBreakIsLong from the script/scheduler path, while BreakHandlerV2Overlay.render reads it through isCurrentBreakLong() later. Add volatile or use the same lock for both reads and writes so the overlay shows the current break type reliably.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/breakhandler/breakhandlerv2/BreakHandlerV2Script.java`
around lines 74 - 75, Update the currentBreakIsLong field in
BreakHandlerV2Script to provide thread-safe visibility between the
script/scheduler writer and BreakHandlerV2Overlay.render’s isCurrentBreakLong()
reader, preferably by declaring it volatile or consistently synchronizing both
access paths.

@MuffinKid23 MuffinKid23 changed the title Add optional long breaks to Break Handler V2 Add optional long and mega breaks to Break Handler V2 Aug 10, 2026
@chsami

chsami commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution. Before this is ready to merge, please address the following:

  1. Retarget the PR from main to development so it goes through the repository's integration branch and CI.
  2. Resolve the two open review findings:
    • The default long-break interval currently occurs before the normal playtime window, so enabling long breaks can continually preempt normal breaks. Adjust the defaults or preserve the normal-break deadline.
    • currentBreakIsLong is written by the script/scheduler path and read by the overlay thread without guaranteed visibility. Make it volatile or synchronize both access paths.
  3. Re-run CI after updating the branch and confirm the normal build passes.

Once those are addressed, we can review it again for merge.

@MuffinKid23
MuffinKid23 changed the base branch from main to development August 12, 2026 03:25
@MuffinKid23

Copy link
Copy Markdown
Author

Addressed the review feedback:

  • Retargeted the PR from main to development.
  • Updated Break Handler V2 defaults so normal breaks run before long breaks by default: normal playtime 7-15 minutes, normal duration 2-3 minutes, long interval 20-30 minutes, long duration 8-11 minutes, mega interval 120-180 minutes, mega duration 20-30 minutes.
  • Made the current break-type flags read by the overlay �olatile for cross-thread visibility.
  • Re-ran ./gradlew.bat :client:compileJava -x test locally and it passed.

chsami commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Thanks for the update. The volatile finding is fixed, but this still is not merge-ready for two reasons:

  1. The timing fix changes the existing normal defaults from 45–90 minutes / 5–15 minutes to 7–15 minutes / 2–3 minutes just to make the 20–30 minute long-break timer occur later. That is a large behavior change for every existing default user. Please preserve the current normal defaults and either move the long-break default interval beyond the normal window or preserve the normal-break deadline when a long break completes.
  2. The PR currently contains 31 unrelated release/generated files (gradle.properties, legacy/gameval IDs, and many rs2asm/hash files). Please rebase onto current development or cherry-pick/squash only the three Break Handler V2 files onto a fresh branch from development.

After the scope is clean and the timing behavior is corrected, please let the repository Build check run; the current PR still has no Build result.

@MuffinKid23
MuffinKid23 force-pushed the breakhandler-v2-long-break branch from 39535e3 to 2b3f3a5 Compare August 14, 2026 20:50
@MuffinKid23

Copy link
Copy Markdown
Author

Addressed the latest review feedback:

  • Rebuilt/force-pushed the branch from current development with a clean scope: only the three Break Handler V2 files are changed.
  • Preserved the existing normal defaults: 45-90 minutes playtime and 5-15 minutes break duration.
  • Made long/mega breaks opt-in by default, and moved their default intervals beyond the normal window:
    • long: 120-180 minutes, 8-11 minutes duration
    • mega: 240-360 minutes, 20-30 minutes duration
  • Kept the break type flags volatile.
  • Ran ./gradlew.bat :client:compileJava -x test --no-daemon locally and it passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants