You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: keep variants usable when tweakcc cannot patch - #54
This PR adds graceful degradation when tweakcc fails to patch the Claude Code binary in a known-recoverable way (validation failures, Bun CommonJS wrapper issues, node-lief errors). Instead of aborting variant creation/update, the build continues with the pristine native runtime and marks tweakcc as disabled in the capability metadata. A regression test covers the async create path.
The fix is focused and the intent is clear. A few issues worth addressing below.
Issues
1. handleTweakccFailure() is copy-pasted between two classes
TweakccStep and TweakccUpdateStep each define an identical private handleTweakccFailure() method. Both BuildContext and UpdateContext share the relevant shape (prefs.promptPackEnabled, prefs.promptPackPreference, state.notes). Extract a standalone function in errors.ts (or a shared tweakcc-helpers.ts) that accepts that minimal interface, and call it from both steps.
// errors.ts (or a new shared module)exportfunctionapplyTweakccFallback(output: string,prefs: {promptPackEnabled: boolean;promptPackPreference: boolean},notes: string[]): void{constmessage=formatTweakccFailure(output);if(!isRecoverableTweakccFailure(output))thrownewError(message);prefs.promptPackEnabled=false;prefs.promptPackPreference=false;constfallback='Continuing with pristine native runtime; tweakcc theming and prompt pack were skipped.';if(!notes.includes(message))notes.push(message);if(!notes.includes(fallback))notes.push(fallback);}
The function normalises the input for its own checks but passes the original string to isBunCommonJsWrapperFailure() and isTweakccNativeExtractionFailure(). If those helpers are also case-sensitive, this is fine — but it is easy to miss and should be made explicit (either always normalise before calling helpers, or document that the helpers handle normalisation themselves).
3. The node-lief match is overly broad
normalized.includes('node-lief')
Any output that mentions node-lief anywhere — including partial, unrelated messages — will trigger the recoverable path. Consider tightening this to a more specific phrase (e.g. 'cannot find module' + 'node-lief', or the exact error string emitted by tweakcc), or add a comment explaining why the substring alone is sufficient.
4. settingsOnly fallback in FinalizeUpdateStep could silently disable tweakcc
The final ?? false means that if neither meta.capabilities nor a provider profile is present, tweakccEnabled silently becomes false. That scenario is unlikely, but the existing ?? chain already covers it through profile?.features.tweakcc.defaultEnabled. The trailing ?? false is correct as a last resort but worth a comment so a future reader doesn't remove it thinking it's redundant.
Minor Observations
Missing return-type annotation: handleTweakccFailure(ctx, output) returns void but the return type is not annotated. The rest of the step classes seem to annotate method signatures consistently.
execute() sync path not tested: The new test only exercises executeAsync(). The sync execute() path goes through the same handleTweakccFailure() but has no dedicated test. Given the duplicated code, a bug could live in one path without being caught by the other's test.
process.env.PATH mutation in test: Mutating PATH and relying on finally for cleanup is fine for sequential tests but could be fragile if the Node test runner ever parallelises within a process. Mocking the subprocess spawn would be more robust, though the current approach is pragmatic and consistent with other e2e-style tests in this repo.
Summary
The core logic is sound and the metadata propagation through FinalizeStep / FinalizeUpdateStep is correct. The main ask before merging is deduplicating handleTweakccFailure — having two identical copies is the kind of thing that will diverge silently when the next edge case is added. The other items are lower priority but worth a look.
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
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.
Summary
Validation
This PR is intended to unblock the Windows smoke failure before publishing v2.2.3.