Repository navigation
Add the Langdock provider - #819
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No identified issue blocks merging. Cookie authentication fails closed, and turning the cookie source Off prevents Langdock requests. Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)✅ Passed checks (7 passed)Full details: Provider Data Stays Siloed
✨ Finishing Touches
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 |
# Conflicts: # apps/desktop-tauri/src/components/providers/providerIcons.ts # apps/desktop-tauri/src/test/providerCatalog.ts # docs/PROVIDERS.md # rust/src/core/provider.rs # rust/src/core/provider_factory.rs # rust/src/core/token_accounts.rs # rust/src/settings/api_keys.rs
# Conflicts: # apps/desktop-tauri/src/components/providers/providerIcons.ts # apps/desktop-tauri/src/test/providerCatalog.ts # docs/PROVIDERS.md # rust/src/core/provider.rs # rust/src/core/provider_factory.rs # rust/src/settings/api_keys.rs
# Conflicts: # README.md # apps/desktop-tauri/src/components/providers/providerIcons.ts # apps/desktop-tauri/src/test/providerCatalog.ts # rust/src/core/provider.rs # rust/src/core/provider_factory.rs # rust/src/core/token_accounts.rs
- Automatic cookie source: the provider now owns browser cookie resolution. It reads every detected browser's langdock.com cookies and uses the first one with a non-empty auth_token (upstream requiredCookies), instead of the shell's first browser with any langdock.com cookie. Manual headers and an empty Manual or Off source never read a browser. - No included limits: one informational primary labelled "Included limits" (upstream detail title) with no duplicate detail row, so the card no longer shows the message twice under "Session". - Correct the overage comment: RateWindow clamps when the window is built, not at display time.
- A missing key (shared resolve_api_key NotInstalled) now maps to upstream IBMBobUsageFetcher's "Missing IBM Bob API key. Add one in Settings or set BOBSHELL_API_KEY." instead of the generic "API key not found" text; before, only a blank key reached it. Other resolver errors still propagate. - New pure helper api_key_from; hermetic test a_missing_key_uses_the_ibm_bob_message.
- HTTP 401/403 ("ClawRouter rejected the API key...") now maps to
NeedsAuthentication via error_state_kind, matching upstream's
authenticationExpired; the message text is unchanged and other
errors keep the default mapping.
- HTTP tests no longer read CLAWROUTER_BASE_URL: the env fallback is an
injected lookup that the test constructor disables.
- Port upstream's budgeted golden fixture (0.024% used, $25 limit,
openai before anthropic, reset 2026-08-01Z) as a literal test.
- Stop attaching the weekly USD CostSnapshot to the fetch result. Upstream SyntheticProviderDescriptor hides the cost block on the card (ProviderCostPresentation(menuCardStyle: .hidden)), and core has no per-provider "hidden on card" flag. The parsed credits still drive the weekly regen line. As a result the weekly cost also leaves CLI JSON. QuotaCost.resets_at was only used for that snapshot and is removed. - Port upstream's "Synthetic fixture matches the cut-over golden" (ProviderPluginParityTests.swift) and "missing rolling lane keeps weekly and search slots" (SyntheticProviderTests.swift) as literal tests. Weekly used percent is 1.9411527777777593, not upstream's 1.9411527777777735: serde_json without float_roundtrip reads 98.05884722222223 one ULP high (1.4e-14, never visible). - Use the fixed NOW in the bearer-request test instead of Utc::now(). - docs/PROVIDERS.md: the weekly credits no longer give a USD cost.
Synthetic's Mac brand color #141414 is near-black, so the palette's brandColorOnDark lifts it on dark surfaces like v0 and TypeSafe; list it in the registry test.
# Conflicts: # apps/desktop-tauri/src/components/providers/providerIcons.ts
# Conflicts: # apps/desktop-tauri/src/components/providers/providerIcons.ts
# Conflicts: # apps/desktop-tauri/src/components/providers/providerIcons.ts
Stacked on #818; merge in order 808 → 810 → 818 → 819 → 821 → 814 → 817; the diff shows predecessors until they merge.
What users get
A new Langdock provider (app.langdock.com) for personal usage limits. It is disabled by default and has no API key.
Cookie source. Settings → Providers → Langdock has the shared cookie-source picker, defaulting to Automatic (upstream instead picks one Edge profile; see Gaps):
langdock.comcookies from the detected browsers, and Manual fails closed without reading a browser.A header without the
auth_tokensession cookie never sends a request.The card shows:
Port and request. Ported from upstream CodexBar v0.73.0
Resources/Plugins/langdock.tsandProviders/Langdock/LangdockProviderDescriptor.swift. It makes one request:GET https://app.langdock.com/api/trpc/usageSettings.getPersonalUsage?batch=1&input=…. The input is upstream's encoded tRPC batch input, sent with Accept and the usage-page Referer.Errors and safety.
UNAUTHORIZEDis reported as an expired session.Files
rust/src/providers/langdock/{mod.rs,model.rs,tests.rs}: fetch, tRPC envelope parse and card mappingWiring per the new-provider recipe:
core/provider.rs:ProviderId::Langdock(clilangdock, cookie domainlangdock.com, colour #5A4AE7)core/provider_factory.rs: factory armcore/token_accounts.rs:Nonearmproviders/mod.rsFrontend:
ProviderIcon-langdock.svg,providerIcons.ts,test/providerCatalog.tsDocs:
docs/PROVIDERS.md(new "Langdock personal usage" section),README.md(provider table row)Cookie-source picker (second and third commits, following the Groq precedent in 5a44b63):
commands/provider_settings.rs: Automatic / Manual / Off options and the id mappingrust/src/settings.rs: the default cookie source is "auto"providers/langdock/mod.rs: an empty Manual source fails closed (ManualEmptyCookiePolicy::FailClosedWeb)rust/src/settings/tests.rsandcommands/session_cookie_scope_tests.rsNo i18n or dependency changes; the picker reuses the existing option labels.
Tests
16 tests in
langdock/tests.rs(11 unit, 5 local-server). They use fixed fixtures and assert literal values.auth_tokennever sends a request.Two more tests cover the picker:
langdock_cookie_source_defaults_to_automatic_session_import(settings): the default is "auto".langdock_exposes_a_cookie_source_picker_and_routes_each_choice(tauri): the options are [auto, manual, off]; a stored header is used under Automatic and Manual; an empty Manual source is Web withmanual_cookie_missing; Off reaches the provider as Cli with no header.Commands
cargo fmt --all -- --checkcargo test --manifest-path rust/Cargo.tomlcargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warningscargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.tomlcargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warningspnpm testpnpm run lintpnpm run buildThe cargo rows ran on the picker commit (d722ffe) and again on the head commit (dea953c), which only rewords three comments: 3819 passed, 1 ignored and tauri 638 both times. The pnpm rows ran on the first commit (0a14898); the picker commit touches no frontend files.
The branch is based on 44d5de3, and the checks ran on that base. It predates #813 (the Mac card anatomy), so the panel proof and the card-layout gaps below describe the card before #813. Main's later Providers-pane changes (the usage-details section and #816's Settings panes) don't touch the cookie-source or API-key sections, and
cookie_source_options_forand the API-key catalog are unchanged on main.Proof (Windows, synthetic data only)
build-proof.sh). The proof-shim patch is never committed.win_run.pywith the Langdock scenario pack. It uses a synthetic Manualauth_tokencookie and a mockedapp.langdock.com; the tRPC GET returned 200 with exactly upstream's encoded input.W:/mac-parity/report/provider-langdock/panel.pngW:/mac-parity/report/provider-langdock/COMPARISON.mdresult.jsonandmock.log, in the same folderwin_run.py --mode settings:providers --target settingswith a copy of the pack that lists this provider first (W:/mac-parity/report/provider-langdock/settings-pack/).W:/mac-parity/report/provider-langdock/settings-proof/settings-before.pngand.jsonW:/mac-parity/report/provider-langdock/settings-proof/settings-after.pngand.jsonGaps vs the Mac card
Sibling PR conflicts
This is one of seven provider PRs: Synthetic (#808), ClawRouter (#810), IBM Bob (#818), Langdock (#819), LithosAI (#821), MuseAI (#814) and WorkBuddy (#817). They all add lines at the same anchors, so expect trivial textual conflicts once one of them merges. Keep both sides. The shared anchors are:
ProviderIdlists incore/provider.rs(after Vercel), including theall().len()count in its testproviders/mod.rstoken_accounts.rsproviderCatalog.tsand theproviderIcons.tsregistrydocs/PROVIDERS.mdsection and README table rowsThe four cookie providers (Langdock #819, LithosAI #821, MuseAI #814 and WorkBuddy #817) also share the picker commit's anchors, so they conflict with each other there:
rust/src/settings.rs: each PR rewrites the default cookie-source armKimi | Hyper | Groq => "auto"to add its variant. Keep every variant in the arm.commands/provider_settings.rs: each PR adds lines after thegroqentries incookie_source_providerandcookie_source_options_for.rust/src/settings/tests.rs: each PR adds a default test after the Groq default test.commands/session_cookie_scope_tests.rs: each PR appends a test at the end of the file.