Skip to content

Add the Langdock provider - #819

Merged
Finesssee merged 34 commits into
mainfrom
feat/provider-langdock
Oct 11, 2026
Merged

Finesssee merged 34 commits into
mainfrom
feat/provider-langdock

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

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):

  • Automatic and Manual first use a header imported under Browser Cookies (from the browser you choose) or pasted there.
  • Without a stored header, Automatic reads the langdock.com cookies from the detected browsers, and Manual fails closed without reading a browser.
  • Off reads nothing.

A header without the auth_token session cookie never sends a request.

The card shows:

  • Session (5-hour window) and Weekly percentages, each with its reset.
  • A plan without session limits shows the weekly lane alone, labelled Weekly.
  • A workspace without included limits shows one "Included limits" detail row.
  • The login method reads "Browser session".

Port and request. Ported from upstream CodexBar v0.73.0 Resources/Plugins/langdock.ts and Providers/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.

  • A 401 or a tRPC UNAUTHORIZED is reported as an expired session.
  • Other tRPC codes and HTTP statuses use upstream's messages.
  • Redirects are not followed, and the response is capped at 512 KiB.
  • Response bodies are never echoed in errors.

Files

  • rust/src/providers/langdock/{mod.rs,model.rs,tests.rs}: fetch, tRPC envelope parse and card mapping

  • Wiring per the new-provider recipe:

    • core/provider.rs: ProviderId::Langdock (cli langdock, cookie domain langdock.com, colour #5A4AE7)
    • core/provider_factory.rs: factory arm
    • core/token_accounts.rs: None arm
    • providers/mod.rs
  • Frontend: ProviderIcon-langdock.svg, providerIcons.ts, test/providerCatalog.ts

  • Docs: 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 mapping
    • rust/src/settings.rs: the default cookie source is "auto"
    • providers/langdock/mod.rs: an empty Manual source fails closed (ManualEmptyCookiePolicy::FailClosedWeb)
    • tests in rust/src/settings/tests.rs and commands/session_cookie_scope_tests.rs

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

  • Request: the batch input decodes to upstream's JSON.
  • Card mapping:
    • The contributor fixture maps to Session and Weekly.
    • The parity-pack payload maps to Session 42% and Weekly 63%.
    • Weekly-only plans put the weekly lane first under its own label.
    • Null resets stay unknown.
    • Missing included limits show one detail row and no bars.
  • Malformed input: malformed envelopes, percentages and dates fail instead of fabricating zero.
  • Errors:
    • tRPC error codes map to upstream messages, and so do HTTP statuses.
    • An expired session is classified as expired.
  • Metadata: matches the upstream descriptor.
  • Local server:
    • The tRPC request is sent with the session cookie.
    • A header without auth_token never sends a request.
    • A Manual source without a cookie does not read a browser.
    • Errors do not echo the body.
    • Off and OAuth do not fetch.

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 with manual_cookie_missing; Off reaches the provider as Cli with no header.

Commands

Command Result
cargo fmt --all -- --check pass
cargo test --manifest-path rust/Cargo.toml pass (3819 passed, 1 ignored)
cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings pass
cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml pass (638)
cargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings pass
pnpm test pass (107 files, 831 tests)
pnpm run lint pass (only existing warnings, none in changed lines)
pnpm run build pass

The 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_for and the API-key catalog are unchanged on main.

Proof (Windows, synthetic data only)

  • Build: a debug build of this branch's commit (0a14898), made through the parity rig (build-proof.sh). The proof-shim patch is never committed.
  • Capture: win_run.py with the Langdock scenario pack. It uses a synthetic Manual auth_token cookie and a mocked app.langdock.com; the tRPC GET returned 200 with exactly upstream's encoded input.
  • Files:
    • Windows panel: W:/mac-parity/report/provider-langdock/panel.png
    • comparison: W:/mac-parity/report/provider-langdock/COMPARISON.md
    • result.json and mock.log, in the same folder
  • Result: the card shows "Langdock", "Browser session", "Session 58% left", "Resets in 2h 30m", "Weekly 37% left" and "Resets in 4d". These match the card the pack derives from langdock.ts.
  • Settings picker: win_run.py --mode settings:providers --target settings with a copy of the pack that lists this provider first (W:/mac-parity/report/provider-langdock/settings-pack/).
    • Before, on the first commit (0a14898): the provider pane has no "Cookie source" section. W:/mac-parity/report/provider-langdock/settings-proof/settings-before.png and .json
    • After, on the picker commit (d722ffe; the head commit only rewords comments): the pane shows "Cookie source" with Automatic, Manual (selected, from the pack's settings) and Disabled. W:/mac-parity/report/provider-langdock/settings-proof/settings-after.png and .json
    • The panel proof above still holds: the pack sets the Manual source with a synthetic header, so the picker commit does not change its routing or the card.

Gaps vs the Mac card

  • No Mac capture exists. Langdock arrived upstream in 0.73.0, after the 0.70.0 Mac baseline, and the Mac pack is blocked: upstream reads only one selected Edge profile through the Keychain. The comparison is against the pack's expected values.
  • Cookie source differs from upstream. Upstream reads a single Edge profile chosen in Settings and offers no manual cookie. On Windows, an explicit import under Browser Cookies (any supported browser) or a pasted header comes first, and Automatic otherwise reads the detected browsers. Upstream also re-reads the profile after the fetch to confirm the session did not change; Windows does not.
  • Usage above 100% is clamped. Upstream keeps it; the Windows bar clamps at 100%.
  • Extra pace lines. The shared Windows card adds reserve/deficit lines for the 5-hour and weekly windows.
  • English only. Detail strings are not translated.

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:

  • ProviderId lists in core/provider.rs (after Vercel), including the all().len() count in its test
  • the factory arm and providers/mod.rs
  • token_accounts.rs
  • providerCatalog.ts and the providerIcons.ts registry
  • the docs/PROVIDERS.md section and README table rows

The 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 arm Kimi | Hyper | Groq => "auto" to add its variant. Keep every variant in the arm.
  • commands/provider_settings.rs: each PR adds lines after the groq entries in cookie_source_provider and cookie_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.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 288b841f-f7fc-4a53-9421-32f899395abc

📥 Commits

Reviewing files that changed from the base of the PR and between dea953c and 0709806.


⛔ Files ignored due to path filters (4)
  • apps/desktop-tauri/src/components/providers/icons/ProviderIcon-clawrouter.svg is excluded by !**/*.svg
  • apps/desktop-tauri/src/components/providers/icons/ProviderIcon-ibmbob.svg is excluded by !**/*.svg
  • apps/desktop-tauri/src/components/providers/icons/ProviderIcon-langdock.svg is excluded by !**/*.svg
  • apps/desktop-tauri/src/components/providers/icons/ProviderIcon-synthetic.svg is excluded by !**/*.svg

📒 Files selected for processing (41)
  • README.md
  • apps/desktop-tauri/src-tauri/src/commands/provider_settings.rs
  • apps/desktop-tauri/src-tauri/src/commands/session_cookie_scope_tests.rs
  • apps/desktop-tauri/src/components/providers/providerIcons.test.ts
  • apps/desktop-tauri/src/components/providers/providerIcons.ts
  • apps/desktop-tauri/src/i18n/keys.ts
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/WayfinderGatewaySection.test.tsx
  • apps/desktop-tauri/src/surfaces/settings/providers/sections/WayfinderGatewaySection.tsx
  • 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/locale.rs
  • rust/src/locale/en-US.ftl
  • rust/src/locale/es-MX.ftl
  • rust/src/locale/ja-JP.ftl
  • rust/src/locale/ko-KR.ftl
  • rust/src/locale/pt-BR.ftl
  • rust/src/locale/ru-RU.ftl
  • rust/src/locale/tests.rs
  • rust/src/locale/tr-TR.ftl
  • rust/src/locale/uk-UA.ftl
  • rust/src/locale/zh-CN.ftl
  • rust/src/locale/zh-TW.ftl
  • rust/src/providers/clawrouter/mod.rs
  • rust/src/providers/clawrouter/model.rs
  • rust/src/providers/clawrouter/tests.rs
  • rust/src/providers/ibmbob/fixtures/profile.json
  • rust/src/providers/ibmbob/mod.rs
  • rust/src/providers/ibmbob/model.rs
  • rust/src/providers/ibmbob/tests.rs
  • rust/src/providers/langdock/mod.rs
  • rust/src/providers/langdock/model.rs
  • rust/src/providers/langdock/tests.rs
  • rust/src/providers/mod.rs
  • rust/src/providers/synthetic/mod.rs
  • rust/src/providers/synthetic/tests.rs
  • rust/src/settings.rs
  • rust/src/settings/api_keys.rs
  • rust/src/settings/tests.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: nesszer/Win-CodexBar/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 292d1eed-90c1-4718-b226-25b4e9420e60









📥 Commits

Reviewing files that changed from the base of the PR and between 4d6b60d and dea953c.










⛔ Files ignored due to path filters (1)
  • apps/desktop-tauri/src/components/providers/icons/ProviderIcon-langdock.svg is excluded by !**/*.svg









📒 Files selected for processing (15)
  • README.md
  • apps/desktop-tauri/src-tauri/src/commands/provider_settings.rs
  • apps/desktop-tauri/src-tauri/src/commands/session_cookie_scope_tests.rs
  • 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/providers/langdock/mod.rs
  • rust/src/providers/langdock/model.rs
  • rust/src/providers/langdock/tests.rs
  • rust/src/providers/mod.rs
  • rust/src/settings.rs
  • rust/src/settings/tests.rs









Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.











📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Langdock is added as a provider for personal usage retrieval. It uses browser or manual session cookies, parses session and weekly usage limits, and supports automatic, manual, and disabled cookie-source settings.

Changes

Langdock personal-usage provider

Layer / File(s) Summary
Usage response parsing
rust/src/providers/langdock/model.rs, rust/src/providers/langdock/tests.rs
Parses Langdock usage envelopes, included-limit states, session and weekly windows, and upstream errors. Tests cover valid data, missing limits, and malformed responses.
Cookie-backed usage retrieval
rust/src/providers/langdock/mod.rs, rust/src/providers/langdock/tests.rs
Retrieves usage with a manual or browser session cookie. Maps HTTP and session errors, limits response size, and tests request and error behavior.
Provider and cookie-source registration
rust/src/core/provider.rs, rust/src/core/provider_factory.rs, rust/src/core/token_accounts.rs, rust/src/providers/mod.rs, rust/src/settings.rs, rust/src/settings/tests.rs, apps/desktop-tauri/src-tauri/src/commands/provider_settings.rs, apps/desktop-tauri/src-tauri/src/commands/session_cookie_scope_tests.rs, apps/desktop-tauri/src/components/providers/providerIcons.ts, apps/desktop-tauri/src/test/providerCatalog.ts, README.md, docs/PROVIDERS.md
Registers Langdock in provider mappings, construction, settings, and desktop presentation. Documents the personal-usage flow and adds provider and cookie-source tests.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LangdockProvider
  participant BrowserCookieStore
  participant LangdockEndpoint
  participant parse_personal_usage
  LangdockProvider->>BrowserCookieStore: Resolve auth_token cookie
  BrowserCookieStore-->>LangdockProvider: Return cookie header
  LangdockProvider->>LangdockEndpoint: Request personal usage
  LangdockEndpoint-->>LangdockProvider: Return response
  LangdockProvider->>parse_personal_usage: Parse response body
  parse_personal_usage-->>LangdockProvider: Return usage result
Loading





































Merge Risk: ⚪ Minimal · up to dea95

No identified issue blocks merging. Cookie authentication fails closed, and turning the cookie source Off prevents Langdock requests.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Provider Data Stays Siloed Error The Langdock provider does not mix identity, plan, account-label, or email data with another provider. However, the change adds provider-specific branching in shared code. rust/src/settings.rs now m… Remove the Langdock-specific ProviderId branches from shared settings and token-account code. Expose these capabilities through provider-local metadata or a generic capability interface resolved by the factory. Apply the same approach to …
✅ Passed checks (7 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Secrets Handled Safely Passed The Langdock implementation obtains cookies through the shared browser-cookie and normalized-header helpers, then uses the credentialed HTTP client only to send the Cookie header. The only new tracing…
No Unapproved Dependencies Passed The authoritative PR diff changes no Cargo.toml, package.json, npm/yarn lockfile, or pnpm packageManager setting. The change adds no dependency, so maintainer approval is not required.
Ui Changes Include Windows Proof Passed The PR changes visible UI: it adds the Langdock provider icon and catalog entry under apps/desktop-tauri/src. The description includes a Windows proof note for a debug build of the branch commit and…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title is a short imperative summary and accurately describes the main change: adding the Langdock provider.




Full details: Provider Data Stays Siloed

Explanation

The Langdock provider does not mix identity, plan, account-label, or email data with another provider. However, the change adds provider-specific branching in shared code. rust/src/settings.rs now matches ProviderId::Langdock to apply an automatic cookie-source default, and rust/src/core/token_accounts.rs now matches ProviderId::Langdock to classify token-account support. Both files are outside rust/src/providers/langdock/ and rust/src/core/provider_factory.rs, so they meet the explicit cross-provider-branching failure condition.

Resolution

Remove the Langdock-specific ProviderId branches from shared settings and token-account code. Expose these capabilities through provider-local metadata or a generic capability interface resolved by the factory. Apply the same approach to any equivalent provider-specific UI branching, while retaining only registry wiring that does not implement provider behavior.





✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR










🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

















  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-merge checks failed. Please resolve the failing checks before merging.

# 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.
@Finesssee
Finesssee merged commit 641d298 into main Oct 11, 2026
3 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