Skip to content

fix(cache): preserve full varp values on varbit changes - #2132

Merged
chsami merged 3 commits into
chsami:developmentfrom
BluBambu:fix/varbit-parent-varp-cache
Nov 1, 2026
Merged

chsami merged 3 commits into
chsami:developmentfrom
BluBambu:fix/varbit-parent-varp-cache

Conversation

@BluBambu

Copy link
Copy Markdown
Contributor

VarbitChanged supplies the changed bitfield value even when it also identifies the parent varp. Copying it into both caches could replace a full value such as 384 with 1, leaving scripts with incorrect player state.

Read the full parent varp from the client for varbit events, preserving unrelated bits and retaining the event value for varp-only updates.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cce24841-0643-4718-be85-5f121be05408

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

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0a953557-3642-4b81-90c3-1bc315b106ef
Commits

Reviewing files that changed from the base of the PR and between 31061af and 27d39c1.

Files selected for processing: 2
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/api/playerstate/Rs2PlayerStateCache.java
  • runelite-client/src/test/java/net/runelite/client/plugins/microbot/api/playerstate/Rs2PlayerStateCacheTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

When a varbit event includes a parent varp, the cache now reads the full parent varp value from the client. Events without a parent varp continue to use the event value. Tests cover preserved parent-varp bits, cleared varbits, events without a parent varp, and cache rereads after hopping.

Merge Risk: Minimal · previous review 27d39

The change preserves parent-varp bits; no merge-blocking risk was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: varbit change handling now preserves full parent varp values in the cache. It matches the summary and objectives. It is short and specific, so it passes.
Description check Passed The description states the problem and the fix. It says varbit events now read the full parent varp from the client, and varp-only updates keep the event value. This relates directly to the changeset,…
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.
Full details: Description check

Explanation

The description states the problem and the fix. It says varbit events now read the full parent varp from the client, and varp-only updates keep the event value. This relates directly to the changeset, so it passes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chsami chsami left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for this fix. Storing only the bitfield value as the whole varp was a real bug, and refreshing the parent value means scripts reading a varp after a varbit change now see the correct number.

  1. runelite-client/src/main/java/net/runelite/client/plugins/microbot/api/playerstate/Rs2PlayerStateCache.java:105 - CI is red because of the new client.getVarpValue(...) call. Run 40708893640 fails :client:runUnitTests in ClientThreadGuardrailTest > rs2AndQueryApiMustNotCallInferredListMethodsOffClientThread with one new violation: Rs2PlayerStateCache#onVarbitChanged(VarbitChanged) -> Client#getVarpValue(int). The guardrail keeps client API calls in the Rs2/Query API from running off the client thread, which is what causes random wrong values and crashes for players. The PR cannot merge while this test fails. Smallest acceptable direction, pick one:
    • Do not read the client here: for varbit events, call varps.remove(event.getVarpId()) so the next getVarpValue refetches the full value through the existing path. This drops the new call entirely and still fixes the bug (adjust the tests to match).
    • Or, since onVarbitChanged is an event handler that already runs on the client thread, keep the call and regenerate the baseline with -Dmicrobot.guardrail.regenerate-baseline=true, then commit the baseline diff so the exception is visible in review.

Push an update or reply here and the maintainer bot reviews it again on a later run.

chsami and others added 2 commits November 1, 2026 06:48
… the client

The varbit event handler is guarded against client API calls. Removing the
cached parent varp lets the next read refetch the full value through the
existing client-thread path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X2jMX5mBiWgqWdWSSPcBDW

@chsami chsami left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Applied the requested direction: varbit events now drop the cached parent varp instead of reading the client, so the next read refetches the full value on the client thread. Guardrail and cache tests pass. Thanks for the fix.

@chsami
chsami merged commit 9085eb1 into chsami:development Nov 1, 2026
2 checks 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