Skip to content

feat(go2): v2.3.0 persist --disable-confirm and add --confirm-distance threshold#2323

Open
mrhoribu wants to merge 1 commit into
masterfrom
feat/go2-v2.3.0-1
Open

feat(go2): v2.3.0 persist --disable-confirm and add --confirm-distance threshold#2323
mrhoribu wants to merge 1 commit into
masterfrom
feat/go2-v2.3.0-1

Conversation

@mrhoribu
Copy link
Copy Markdown
Contributor

@mrhoribu mrhoribu commented May 12, 2026

  • Add --disable-confirm=on/off persistent flag; bare --disable-confirm retains existing one-shot behavior
  • Add --confirm-distance= to configure the distance threshold (replaces hardcoded 20); minimum value 20, default 20
  • Seed CharSettings['disable_confirm']=false and CharSettings['confirm_distance']=20 on first run for back-compat
  • Show both settings in ;go2 list output and help text

Summary by CodeRabbit

  • New Features
    • Updated go2 script to v2.3.0 with persistent trip confirmation configuration
    • Added --disable-confirm flag to customize trip confirmation behavior
    • Added --confirm-distance flag to set a custom confirmation distance threshold (minimum 20)
    • New settings are automatically initialized and persist across sessions

Review Change Stack

…e threshold

- Add --disable-confirm=on/off persistent flag; bare --disable-confirm retains existing one-shot behavior
- Add --confirm-distance=<N> to configure the distance threshold (replaces hardcoded 20); minimum value 20, default 20
- Seed CharSettings['disable_confirm']=false and CharSettings['confirm_distance']=20 on first run for back-compat
- Show both settings in `;go2 list` output and help text
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

The go2 script is updated to version 2.3.0 with configurable trip confirmation behavior. Two new persistent settings—disable_confirm and confirm_distance—are initialized, exposed in help and list output, parsed from CLI flags, persisted when provided, and applied throughout trip confirmation logic to replace the hardcoded distance threshold.

Changes

Trip Confirmation Settings

Layer / File(s) Summary
Version and release notes
scripts/go2.lic
Version bumped to 2.3.0 with changelog entries documenting persistent disable_confirm and confirm_distance configuration.
Settings initialization defaults
scripts/go2.lic
New settings disable_confirm (default false) and confirm_distance (default 20) seeded in CharSettings on first run.
User-facing documentation
scripts/go2.lic
Help text extended with --disable-confirm and --confirm-distance flag documentation; list output now displays current setting values.
CLI argument parsing and locals
scripts/go2.lic
Local variables introduced to track settings state; command-line parsing accepts --disable-confirm=<on|off|true|false|yes|no> and --confirm-distance=<N>.
Settings persistence
scripts/go2.lic
When running with settings-only arguments, CharSettings values are persisted with confirm_distance clamped to minimum 20; confirmation messages display resulting defaults.
Trip confirmation distance application
scripts/go2.lic
Guild-target, locker-target, and generic matching-target confirmation decisions updated to use CharSettings['confirm_distance'] (fallback 20) instead of hardcoded distance 20.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main changes: adding persistent --disable-confirm and --confirm-distance threshold features in v2.3.0.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/go2-v2.3.0-1

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/go2.lic (1)

1044-1045: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix Rubocop indentation failure in chained call.

Line 1045 must align .each with .find_all to satisfy Layout/MultilineMethodCallIndentation (currently failing CI).

🤖 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 `@scripts/go2.lic` around lines 1044 - 1045, The chained call indentation for
Map.list.find_all { |iroom| ... }.each is incorrect; move the `.each` to a new
line aligned under `.find_all` so the block passed to `.each` is indented one
level deeper than the call (i.e., align `.each` with `.find_all` and indent the
`{ |iroom| output << ... }` or do-block accordingly) to satisfy
Layout/MultilineMethodCallIndentation for the Map.list.find_all / .each chain
that builds the output string.
🤖 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 `@scripts/go2.lic`:
- Around line 1189-1190: The parsed --confirm-distance
(setting_confirm_distance) is never applied for one-shot trips with a target
because distance checks still read CharSettings['confirm_distance']; update the
trip-start/confirmation logic (where distance is compared against CharSettings,
e.g., in the one-shot target handling and any confirmation checks) to prefer
setting_confirm_distance when it is non-nil, falling back to
CharSettings['confirm_distance'] otherwise; ensure the same change is applied at
the other occurrences that initialize or check setting_confirm_distance so the
flag actually overrides the CharSettings value for one-shot trips.

---

Outside diff comments:
In `@scripts/go2.lic`:
- Around line 1044-1045: The chained call indentation for Map.list.find_all {
|iroom| ... }.each is incorrect; move the `.each` to a new line aligned under
`.find_all` so the block passed to `.each` is indented one level deeper than the
call (i.e., align `.each` with `.find_all` and indent the `{ |iroom| output <<
... }` or do-block accordingly) to satisfy Layout/MultilineMethodCallIndentation
for the Map.list.find_all / .each chain that builds the output string.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78956f2c-dee5-432e-b266-51640cfa3c4b

📥 Commits

Reviewing files that changed from the base of the PR and between 7389607 and d42c555.

📒 Files selected for processing (1)
  • scripts/go2.lic

Comment thread scripts/go2.lic
Comment on lines +1189 to +1190
setting_disable_confirm = (CharSettings['disable_confirm'] == true)
setting_confirm_distance = nil
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot May 12, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

--confirm-distance is parsed but not applied for one-shot trips with a target.

setting_confirm_distance is captured, but distance checks still read from CharSettings only. In ;go2 <options> <target> mode, this flag currently has no effect on the active trip.

Suggested fix
-  setting_confirm_distance        = nil
+  setting_confirm_distance        = nil
+  effective_confirm_distance      = (CharSettings['confirm_distance'] || 20).to_i
...
     elsif var =~ /^(?:\-\-)?confirm[_\-]distance=([0-9]+)$/i
       setting_confirm_distance = $1.to_i
...
+  unless setting_confirm_distance.nil?
+    effective_confirm_distance = [setting_confirm_distance, 20].max
+  end
...
-    if shortest_distances[destination.id] < (CharSettings['confirm_distance'] || 20)
+    if shortest_distances[destination.id] < effective_confirm_distance
...
-    if shortest_distances[destination.id] < (CharSettings['confirm_distance'] || 20)
+    if shortest_distances[destination.id] < effective_confirm_distance
...
-    if shortest_distances[destination.id] < (CharSettings['confirm_distance'] || 20)
+    if shortest_distances[destination.id] < effective_confirm_distance

Also applies to: 1227-1228, 1893-1893, 2028-2028, 2056-2056

🤖 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 `@scripts/go2.lic` around lines 1189 - 1190, The parsed --confirm-distance
(setting_confirm_distance) is never applied for one-shot trips with a target
because distance checks still read CharSettings['confirm_distance']; update the
trip-start/confirmation logic (where distance is compared against CharSettings,
e.g., in the one-shot target handling and any confirmation checks) to prefer
setting_confirm_distance when it is non-nil, falling back to
CharSettings['confirm_distance'] otherwise; ensure the same change is applied at
the other occurrences that initialize or check setting_confirm_distance so the
flag actually overrides the CharSettings value for one-shot trips.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CharSettings['confirm_distance'] is set during initial loading via

CharSettings['confirm_distance']       = 20    if CharSettings['confirm_distance'].nil?

And then later after that, --confirm-distance is parsed via

   elsif var =~ /^(?:\-\-)?confirm[_\-]distance=([0-9]+)$/i
      setting_confirm_distance = $1.to_i

From here, it then gets interpretted to either use that if it existed OR use the CharSettings default of 20.

    unless setting_confirm_distance.nil?
      setting_confirm_distance = 20 if setting_confirm_distance < 20
      CharSettings['confirm_distance'] = setting_confirm_distance
      echo "go2 will prompt for confirmation when the trip distance is at least #{setting_confirm_distance} rooms"
    end

I'm not sure I see the issue you're trying to state.

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.

@mrhoribu, thanks for walking through the flow — but the two cases use different code paths, and the issue is specific to when a target is also provided.

Here's the distinction:

Settings-only mode (;go2 --confirm-distance=30) — target_search_string.empty? is true, so this block runs and correctly persists the value:

if target_search_string.empty?
  ...
  unless setting_confirm_distance.nil?
    CharSettings['confirm_distance'] = setting_confirm_distance  # ✅ saved
    ...
  end
  exit
end

One-shot trip mode (;go2 --confirm-distance=30 bank) — target_search_string is "bank", so the entire if target_search_string.empty? block is skipped entirely. CharSettings['confirm_distance'] is never updated with 30. Execution falls through to the target-finding logic, where the three distance checks all read:

if shortest_distances[destination.id] < (CharSettings['confirm_distance'] || 20)

…which uses the old persisted value (e.g. 20), not the CLI-supplied 30. The setting_confirm_distance local is parsed but silently discarded for the active trip.

The practical consequence: ;go2 --confirm-distance=5 bank would still prompt for confirmation (since the persisted value remains 20), and ;go2 --confirm-distance=50 bank would still suppress confirmation for a 40-room trip. The flag only takes effect when no target is given.


🧠 Learnings used
Learnt from: mrhoribu
Repo: elanthia-online/scripts PR: 2266
File: scripts/map.lic:842-849
Timestamp: 2026-03-09T17:48:29.654Z
Learning: In elanthia-online/scripts, the runtime pre-creates DATA_DIR/<game> before any script runs. Do not defensively create the data directory in .lic scripts (e.g., map.lic); avoid FileUtils.mkdir_p for the data directory since existence is guaranteed by the runtime. Rely on the guaranteed directory and handle write errors if they occur.

Learnt from: mrhoribu
Repo: elanthia-online/scripts PR: 2269
File: scripts/bigshot.lic:3937-3941
Timestamp: 2026-03-16T18:14:16.217Z
Learning: In the elanthia-online/scripts context, for LIC scripts (e.g., scripts/bigshot.lic), when dothistimeout returns nil on timeout or failed to match, prefer checking result.nil? rather than result == false to distinguish timeout/unmatched cases. This improves robustness by treating nil as timeout/unmatched and false as an explicit false value.

Learnt from: mrhoribu
Repo: elanthia-online/scripts PR: 2311
File: scripts/eloot.lic:3359-3360
Timestamp: 2026-05-05T14:28:27.392Z
Learning: When using Ruby’s regex match operator (`=~`) with a potentially-nil left-hand side (e.g., `item.type =~ /.../`), Ruby returns `nil` for `nil =~ /regex/` and does not raise an exception. If the only goal is to check whether the regex matches (truthy/non-truthy), coercing the value (e.g., `to_s`) is unnecessary for correctness—just make sure the calling code treats a `nil` result as “no match.”

Learnt from: mrhoribu
Repo: elanthia-online/scripts PR: 2313
File: scripts/ledger.lic:69-69
Timestamp: 2026-05-06T14:45:43.889Z
Learning: In elanthia-online/scripts, Lich5 bundles tzinfo and tzinfo-data by default. For all .lic scripts under the scripts directory, only require 'tzinfo'; tzinfo will load tzinfo-data automatically. Do not declare 'tzinfo-data' as a separate gem dependency in .lic scripts or their gemfiles. If a script currently lists tzinfo-data as a dependency, remove it. This guideline applies to all scripts (*.lic) in this repository.

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