[Repo Assist] refactor: extract TryParseArgv helper in SystemCapability, fix operator precedence#96
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…or precedence
Two related improvements to SystemCapability:
1. Extract TryParseArgv helper: HandleRunPrepare and HandleRunAsync both
contained near-identical JSON argv-array parsing logic (~20 lines each).
Extract into a private static TryParseArgv method. Both callers are
simplified and the parsing contract is documented in one place.
2. Fix operator precedence in HandleExecApprovalsSet: the 'enabled' bool
check was written as:
TryGetProperty(...) && kind == True || kind == False
which C# parses as:
(TryGetProperty(...) && kind == True) || (kind == False)
rather than the intended:
TryGetProperty(...) && (kind == True || kind == False)
Behaviour happened to be correct in all cases (default JsonElement has
ValueKind == Undefined, not False), but the unparenthesised form is
misleading. Added parentheses to make intent explicit.
503 tests pass, 18 skipped (integration/Windows-only).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated contribution from Repo Assist.
Two related improvements to
SystemCapabilityinOpenClaw.Shared.Changes
1. Extract
TryParseArgvhelperHandleRunPrepareandHandleRunAsyncboth contained near-identical ~20-line JSON argv-parsing blocks. Both acceptcommandas either a JSON string array or a single string. The logic is now consolidated into a singleprivate static bool TryParseArgv(JsonElement, out string[])method, with the parsing contract documented in one place.Before: ~40 lines of duplicated argv parsing across two methods.
After: Two calls to
TryParseArgv; each method focuses on its own concern.2. Fix operator precedence in
HandleExecApprovalsSetThe
enabledboolean check was written as:&&binds tighter than||, so this evaluates as(A && B) || Crather than the intendedA && (B || C). Added parentheses to make the intent unambiguous.Test Status
503 tests pass, 18 skipped (integration/Windows-only). The refactor is a pure structural extraction with no logic changes — the observable behaviour of
system.run,system.run.prepare, andsystem.execApprovals.setis unchanged.Closes #91