Skip to content

Add optional long breaks to Break Handler V2 - #1833

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

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

Conversation

@MuffinKid23

Copy link
Copy Markdown

Summary

  • add optional long-break timing configuration to Break Handler V2
  • keep normal breaks independent from the pending long-break timer
  • merge a due long break into an already-active break instead of starting a competing break cycle
  • show runtime, break count, long-break countdown, and long-break status 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

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
Title check ✅ Passed The title clearly and concisely describes the addition of optional long breaks to Break Handler V2.
Description check ✅ Passed The description accurately summarizes the long-break configuration, scheduling behavior, overlay updates, and validation command.
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.

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.

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.

1 participant