feat(go2): v2.3.0 persist --disable-confirm and add --confirm-distance threshold#2323
feat(go2): v2.3.0 persist --disable-confirm and add --confirm-distance threshold#2323mrhoribu wants to merge 1 commit into
Conversation
…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
📝 WalkthroughWalkthroughThe ChangesTrip Confirmation Settings
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winFix Rubocop indentation failure in chained call.
Line 1045 must align
.eachwith.find_allto satisfyLayout/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
| setting_disable_confirm = (CharSettings['disable_confirm'] == true) | ||
| setting_confirm_distance = nil |
There was a problem hiding this comment.
--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_distanceAlso 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.
There was a problem hiding this comment.
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_iFrom 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"
endI'm not sure I see the issue you're trying to state.
There was a problem hiding this comment.
@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
endOne-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.
;go2 listoutput and help textSummary by CodeRabbit
go2script to v2.3.0 with persistent trip confirmation configuration--disable-confirmflag to customize trip confirmation behavior--confirm-distanceflag to set a custom confirmation distance threshold (minimum 20)