feat(onboarding): self-heal a stale provider.harmoniqs entry on extension activation - #967
Merged
Merged
Conversation
…sion activation Found live: a user who connected under alpha.1/alpha.2 (before HARMONIQS_MAX_OUTPUT_TOKENS existed) kept a broken entry forever after upgrading to alpha.3 -- every real chat turn still 400'd. Two compounding gaps made this structural, not a one-off: 1. Installing a new extension version never rewrites an already-written opencode.json -- the fix only changes what gets written going forward. 2. Reconnecting through the UI doesn't help either: once a real provider.harmoniqs entry exists, the Connect Provider picker's branded row hides by design (shouldShowHarmoniqsEntry, amicode#962) so it never duplicates a real catalog entry -- but that routes reconnection through the GENERIC ProviderConnection flow, which only ever touches the API key, never the model shape (limit/tool_call). There was no path back to a healthy config short of hand-editing the file. Add healStaleHarmoniqsModelShape(existing), mirroring the existing healPlantedBedrockEntry precedent one function above it: unconditionally reconciles every model entry under provider.harmoniqs to the current tool_call/limit.output constants (protocol-level facts about this specific gateway, not user preferences -- the preset's base URL and model list are already documented as not user-editable for the same reason). Wired in two places: - Inside writeOnboardingConfig's existing merge path, so ANY future write (even for a different provider) opportunistically heals a lingering stale harmoniqs entry sitting in "existing". - A new standalone reconcileHarmoniqsProviderConfig(), called once on extension activation (extension.ts) -- the actual fix for existing installs, since a user might never trigger another onboarding write at all. Cheap and idempotent: one file read, and a write only when something actually needs healing. Tests: reconciles the exact alpha.1/alpha.2 shape; heals a second hypothetical model id (proving it's not hardcoded to harmoniqs-auto); is a byte-for-byte no-op (mtime unchanged) when already correct; no-ops on a missing file or a config with no harmoniqs entry; and heals via writeOnboardingConfig's merge path when writing an unrelated provider. Verified: 88/88 onboarding_panel tests pass (6 new). Full suite: the same 32 pre-existing failures across 7 unrelated files as bare main (confirmed via git stash). Full pnpm --filter amicode run package succeeds end to end.
|
Warning Review limit reachedNext included review available in 25 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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 |
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.
The gap this closes
Found live: a user who connected under
alpha.1/alpha.2(beforeHARMONIQS_MAX_OUTPUT_TOKENSexisted, #966) kept a broken entry forever after upgrading toalpha.3— every real chat turn still 400'd. Two compounding gaps made this structural, not a one-off:opencode.json— a fix only changes what gets written going forward.provider.harmoniqsentry exists, the Connect Provider picker's branded row hides by design (shouldShowHarmoniqsEntry, feat(onboarding): focused Harmoniqs AI connect entry point for the generic Connect Provider dialog #962) so it never duplicates a real catalog entry — but that routes reconnection through the genericProviderConnectionflow, which only ever touches the API key, never the model shape. There was no path back to a healthy config short of hand-editing the file (which is literally what I had to do live tonight to unblock testing).Fix
healStaleHarmoniqsModelShape(existing), mirroring the existinghealPlantedBedrockEntryprecedent one function above it: unconditionally reconciles every model entry underprovider.harmoniqsto the currenttool_call/limit.outputconstants — these are protocol-level facts about this specific gateway, not user preferences (the preset's base URL and model list are already documented as not user-editable, for the same reason).Wired in two places:
writeOnboardingConfig's existing merge path, so any future write (even for a different provider) opportunistically heals a lingering stale entry.reconcileHarmoniqsProviderConfig(), called once on extension activation — the actual fix for existing installs, since a user might never trigger another onboarding write at all. Cheap and idempotent.Validation
alpha.1/alpha.2shape; heals a second hypothetical model id (not hardcoded); byte-for-byte no-op (mtime unchanged) when already correct; no-ops on a missing file or no-harmoniqs-entry config; heals viawriteOnboardingConfig's merge path when writing an unrelated provider.npx vitest run test/onboarding_panel.test.ts— 88/88 pass.main(confirmed viagit stash).pnpm --filter amicode run packagesucceeds end to end.