feat(soniox): select data-residency region (US/EU/JP) with auto-detect#262
feat(soniox): select data-residency region (US/EU/JP) with auto-detect#262johngambleubind wants to merge 2 commits into
Conversation
The plugin hardcoded the US endpoint (api.soniox.com), so EU (api.eu.soniox.com) and Japan (api.jp.soniox.com) keys could not be used at all — Soniox binds each key to its project's region and domain — and everyone paid US round-trip latency. - Resolve the base URL from a persisted Region setting (default US, so existing installs are unchanged), via IPluginHostServices.GetSetting/SetSetting. - Settings view gains a Region dropdown; the Test button now probes each regional /v1/models with the key and auto-selects the region it authenticates against. Region is bound to the key's project, not the user's location, so probing is the correct detection, not geo/IP. - Bump plugin version to 1.0.4; add tests for region persistence, endpoint switching, unknown-region fallback, and auto-detect (hit + miss). Implements TypeWhisper#261 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds Soniox data-residency region support: a region list (US/EU/JP) with base URLs, persisted region selection, region auto-detection via API-key probing, a computed base URL resolver, a settings UI region selector, plugin version bump to 1.0.4, manifest update, and corresponding tests. ChangesSoniox Region Support
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant SonioxSettingsView
participant SonioxPlugin
participant SonioxAPI
User->>SonioxSettingsView: click Test (API key)
SonioxSettingsView->>SonioxPlugin: DetectRegionAsync(key)
loop each region base URL
SonioxPlugin->>SonioxAPI: GET /v1/models
SonioxAPI-->>SonioxPlugin: authorized/unauthorized
end
SonioxPlugin-->>SonioxSettingsView: detected region or null
SonioxSettingsView->>SonioxSettingsView: ApplyDetectedRegion / show status
SonioxSettingsView->>SonioxPlugin: SetRegion(regionId)
SonioxPlugin->>SonioxPlugin: persist region setting
Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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)
plugins/TypeWhisper.Plugin.Soniox/SonioxSettingsView.xaml.cs (1)
112-131: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winStale test result can clobber a manual region change made during probing.
RegionBoxstays interactive whileDetectRegionAsyncis awaited. If the user changes the region dropdown while Test is running,OnRegionChangedfires and callsSetRegionimmediately; once the pending probe resolves,ApplyDetectedRegionoverwrites that newer selection with the (now stale) detected region.🔒 Suggested fix: disable RegionBox during probing
TestButton.IsEnabled = false; + RegionBox.IsEnabled = false; StatusText.Text = L("Settings.Testing"); StatusText.Foreground = Brushes.Gray; try { ... } finally { TestButton.IsEnabled = true; + RegionBox.IsEnabled = true; }🤖 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 `@plugins/TypeWhisper.Plugin.Soniox/SonioxSettingsView.xaml.cs` around lines 112 - 131, The test flow in SonioxSettingsView.xaml.cs allows a stale async region probe to overwrite a user’s newer manual selection because RegionBox remains editable while DetectRegionAsync is running. Update the Test button handler and/or OnRegionChanged flow in SonioxSettingsView to disable RegionBox for the duration of the probe, then restore it afterward, so ApplyDetectedRegion cannot clobber a region change made during testing.
🤖 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 `@plugins/TypeWhisper.Plugin.Soniox/SonioxPlugin.cs`:
- Around line 222-235: The DetectRegionAsync flow in SonioxPlugin should fail
fast per region instead of letting each ProbeModelsAsync call inherit the full
HttpClient timeout. Update DetectRegionAsync to create a short-lived linked
CancellationTokenSource for each region probe, pass that token into
ProbeModelsAsync, and keep the existing region loop/return behavior in place so
OnTestClick no longer blocks for the full timeout on every region.
---
Outside diff comments:
In `@plugins/TypeWhisper.Plugin.Soniox/SonioxSettingsView.xaml.cs`:
- Around line 112-131: The test flow in SonioxSettingsView.xaml.cs allows a
stale async region probe to overwrite a user’s newer manual selection because
RegionBox remains editable while DetectRegionAsync is running. Update the Test
button handler and/or OnRegionChanged flow in SonioxSettingsView to disable
RegionBox for the duration of the probe, then restore it afterward, so
ApplyDetectedRegion cannot clobber a region change made during testing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2676dc1e-3b4d-4cd5-ac07-32560d03b2e8
📒 Files selected for processing (5)
plugins/TypeWhisper.Plugin.Soniox/SonioxPlugin.csplugins/TypeWhisper.Plugin.Soniox/SonioxSettingsView.xamlplugins/TypeWhisper.Plugin.Soniox/SonioxSettingsView.xaml.csplugins/TypeWhisper.Plugin.Soniox/manifest.jsontests/TypeWhisper.PluginSystem.Tests/SonioxPluginTests.cs
…g test Addresses the CodeRabbit review on TypeWhisper#262: - DetectRegionAsync bounds each probe with a 10s linked-CTS timeout so an unreachable region fails fast instead of blocking the Test flow for the full HttpClient timeout. A probe timeout skips to the next region, while a genuine caller cancellation still propagates -- ProbeModelsAsync re-throws on cancel, so the timeout is caught only when the outer token is not cancelled. - Disable the region dropdown while probing so a manual change mid-Test cannot be clobbered by ApplyDetectedRegion when the probe resolves. Soniox tests still green (24/24). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Both addressed in d251c54:
Soniox suite green (24/24). |
SeoFood
left a comment
There was a problem hiding this comment.
One stale-input case remains in the settings test flow: editing the API key while the region probe is in flight can persist the old key's detected region against the newly saved key.
| var valid = await _plugin.ValidateApiKeyAsync(key); | ||
| StatusText.Text = valid ? L("Settings.ApiKeyValid") : L("Settings.ApiKeyInvalid"); | ||
| StatusText.Foreground = valid ? Brushes.Green : Brushes.Red; | ||
| var detectedRegion = await _plugin.DetectRegionAsync(key); |
There was a problem hiding this comment.
OnTestClick captures ApiKeyBox.Password once, then awaits DetectRegionAsync, but the password box stays editable and OnPasswordChanged can debounce-save a different key while the probe is in flight. When the old probe resolves, ApplyDetectedRegion persists the region detected for the old key against the newly saved key, leaving the plugin with a mismatched key/region pair. Please disable ApiKeyBox during the test as well, or re-check that ApiKeyBox.Password still matches the tested key before applying the detected region.
Implements #261.
What
Adds a data-residency region selection to the Soniox plugin so it isn't locked to the US endpoint.
BaseUrl = "https://api.soniox.com"(US). EU and Japan keys couldn't be used at all — Soniox binds each API key to its project's region and domain — and everyone paid US round-trip latency.api.soniox.com, EUapi.eu.soniox.com, JPapi.jp.soniox.com. Default is US, so existing installs are unchanged.UX
IPluginHostServices.GetSetting/SetSetting— the same mechanism the OpenAI-Compatible plugin already uses for its endpoint./v1/modelswith the key and selects the region that authenticates. Because the region is tied to the key's project (not the user's geography), probing is the reliable way to detect it — one click sets it up correctly.Testing
dotnet test --filter SonioxPluginTests→ all pass (24/24), including 5 new tests:SetRegionpersists the choice and switches the endpoint,nullwhen no region accepts the key.Notes
1.0.3→1.0.4.Summary by CodeRabbit
New Features
Bug Fixes
Chores