Skip to content

feat(onboarding): self-heal a stale provider.harmoniqs entry on extension activation - #967

Merged
jack-champagne merged 1 commit into
mainfrom
feat/harmoniqs-config-reconcile
Sep 10, 2026
Merged

jack-champagne merged 1 commit into
mainfrom
feat/harmoniqs-config-reconcile

Conversation

@jack-champagne

Copy link
Copy Markdown
Member

The gap this closes

Found live: a user who connected under alpha.1/alpha.2 (before HARMONIQS_MAX_OUTPUT_TOKENS existed, #966) 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 — a 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, 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 generic ProviderConnection flow, 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 existing healPlantedBedrockEntry precedent one function above it: unconditionally reconciles every model entry under provider.harmoniqs to the current tool_call/limit.output constants — 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:

  • Inside writeOnboardingConfig's existing merge path, so any future write (even for a different provider) opportunistically heals a lingering stale entry.
  • A new standalone 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

  • 6 new tests: heals the exact alpha.1/alpha.2 shape; 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 via writeOnboardingConfig's merge path when writing an unrelated provider.
  • npx vitest run test/onboarding_panel.test.ts — 88/88 pass.
  • 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.

…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.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c503d742-a534-4ff5-91a1-368c9d9662a9

📥 Commits

Reviewing files that changed from the base of the PR and between f3b008d and 1f5581f.

📒 Files selected for processing (3)
  • packages/extension/src/extension.ts
  • packages/extension/src/onboarding_panel.ts
  • packages/extension/test/onboarding_panel.test.ts

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.

@jack-champagne
jack-champagne merged commit bbd5b74 into main Sep 10, 2026
10 checks passed
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