Skip to content

feat(plugins): add Zed AI provider#558

Open
rohithgoud30 wants to merge 6 commits into
robinebers:mainfrom
rohithgoud30:add-zed-ai-support
Open

feat(plugins): add Zed AI provider#558
rohithgoud30 wants to merge 6 commits into
robinebers:mainfrom
rohithgoud30:add-zed-ai-support

Conversation

@rohithgoud30
Copy link
Copy Markdown
Contributor

@rohithgoud30 rohithgoud30 commented Jun 4, 2026

Description

Adds a Zed AI provider for OpenUsage.

The provider reads Zed app credentials from the macOS Internet Password item for https://zed.dev, with ZED_USER_ID / ZED_ACCESS_TOKEN as a local testing fallback. It calls Zed usage APIs to show token spend, edit prediction usage, and daily spend. This covers Agent Panel and Inline Assistant usage when the selected model provider is Zed-hosted; bring-your-own-key providers and external agents remain billed by their configured service.

The AI Usage quick link is built from the signed-in user API response at runtime, so the PR does not hardcode any account or organization ID.

Related Issue

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test -- --run and all tests pass
  • I tested the change locally with the Tauri dev app
  • I ran cargo test --lib
  • I ran git diff --check

Screenshots

SCREENSHOT_4

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Summary by cubic

Adds a zed provider that shows token spend, edit predictions, and daily spend, with runtime quick links and macOS keychain auth. Also improves quick-link precedence and redacts Zed user/org fields in logs.

  • New Features

    • New zed plugin: Token Spend (progress/text), Edit Predictions (progress/text), Daily Spend chart, Updated timestamp, plan label, overdue invoice badge.
    • Runtime quick links: builds an "AI Usage" URL from the signed-in user and returns it via links; the UI now prefers runtime links over manifest links.
    • Host API: host.keychain.readInternetPassword(server, account?); whitelisted ZED_USER_ID and ZED_ACCESS_TOKEN. Docs updated for the keychain method, runtime links, and Zed’s hosted-model scope; provider docs added; tests included.
  • Bug Fixes

    • Respect empty runtime provider links (no fallback to manifest).
    • Preserve manifest quick links when runtime links is omitted.
    • Zed icon uses currentColor for proper theming.
    • Redact Zed user and organization fields in logs.

Written for commit 81c60a4. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added Zed AI provider (token spend, edit predictions) and support for runtime-provided quick links that override static provider links (empty-array preserves no links).
    • Keychain internet-password support for macOS (host helper documented).
  • Documentation

    • README, provider docs, and plugin API docs updated with Zed details and keychain helper usage.
  • Tests

    • Added tests for the Zed probe, keychain fallback, link precedence, and runtime link handling.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a new Zed AI provider plugin, runtime support for probe-returned quick links, macOS internet-password keychain helpers with a JS wrapper, and the necessary wiring, tests, and docs across Rust, TypeScript, plugins, and frontend.

Changes

Zed AI provider with linked infrastructure

Layer / File(s) Summary
Plugin output links infrastructure
src/lib/plugin-types.ts, src-tauri/src/plugin_engine/runtime.rs, src/pages/provider-detail.tsx, src/pages/provider-detail.test.tsx, docs/plugins/schema.md, src-tauri/src/local_http_api/cache.rs
PluginOutput gains an optional links field; Rust runtime parses and validates HTTP(S) links from JS probe results, preserves links shape for errors/cache, and frontend prefers plugin.data.links over plugin.meta.links when defined.
Internet password keychain helper
src-tauri/src/plugin_engine/host_api.rs, plugins/test-helpers.js, docs/plugins/api.md
Adds internet-password lookup helpers (security find-internet-password arg builders, acct parsing), raw _readInternetPasswordRaw, JS patch_keychain_wrapper exposing readInternetPassword(server, account?), WHITELISTED_ENV_VARS entries for Zed, redaction updates, unit tests, and API docs updates.
Zed provider plugin
plugins/zed/plugin.js, plugins/zed/plugin.json, plugins/zed/plugin.test.js, docs/providers/zed.md, README.md
New Zed plugin: credential sourcing (env or keychain), authenticated calls to user and billing endpoints with fallbacks, normalization of plan/usage and daily spend chart, building of dashboard quick links, status badges, manifest and comprehensive tests plus provider docs and README entry.

Sequence Diagram(s)

sequenceDiagram
  participant Plugin as JS Plugin
  participant Wrapper as JS Wrapper
  participant Raw as Rust _readInternetPasswordRaw
  participant Security as macOS security CLI
  Plugin->>Wrapper: readInternetPassword(server, account?)
  Wrapper->>Raw: Call Rust function
  alt account provided
    Raw->>Raw: Use provided account directly
  else account not provided
    Raw->>Security: security find-internet-password attributes-only
    Security-->>Raw: Output containing acct attribute
    Raw->>Raw: Parse acct value from output
  end
  Raw->>Security: security find-internet-password full lookup
  Security-->>Raw: Password output
  Raw->>Raw: Return { account, password } as JSON
  Wrapper->>Wrapper: Parse JSON result
  Wrapper-->>Plugin: { account, password }
Loading
sequenceDiagram
  participant Probe as probe(ctx)
  participant Keychain as ctx.host.keychain
  participant EnvVar as Environment
  participant Client as /client/users/me
  participant Billing as /frontend/billing/usage
  Probe->>EnvVar: Check ZED_USER_ID, ZED_ACCESS_TOKEN
  alt env credentials present
    Probe->>Probe: Use environment credentials
  else env credentials missing
    Probe->>Keychain: readInternetPassword("https://zed.dev")
    Keychain-->>Probe: { account, password }
  end
  Probe->>Client: Fetch user details
  Client-->>Probe: User/org/plan data
  Probe->>Billing: Fetch billing usage
  alt 401 auth error on billing
    Probe->>Client: Fetch /client/users/me for fallback edit limits
    Client-->>Probe: Edit usage data
  else billing success
    Probe->>Billing: Fetch token spend (optional)
  end
  Probe->>Probe: Normalize plan, compute usage lines, build dashboard links
  Probe->>Probe: Add status badges for overdue/missing data
  Probe-->>Probe: Return { plan, lines, links }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested reviewers

  • validatedev
  • davidarny
  • robinebers
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.81% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(plugins): add Zed AI provider' accurately summarizes the main change—adding a new Zed AI provider plugin—and is concise, clear, and directly related to the changeset.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added rust Pull requests that update rust code core plugin docs labels Jun 4, 2026
@rohithgoud30 rohithgoud30 marked this pull request as ready for review June 4, 2026 16:02
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 15 files

Re-trigger cubic

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/provider-detail.test.tsx (1)

72-103: ⚡ Quick win

Add a regression test for empty runtime links overriding manifest links.

Please add a case where plugin.data.links = [] and plugin.meta.links is non-empty, then assert no quick link renders. That locks in the override behavior and prevents fallback regressions.

As per coding guidelines **/*.{test,spec}.{js,ts,tsx,jsx}: Add regression test when a bug fix fits the test pattern.

🤖 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 `@src/pages/provider-detail.test.tsx` around lines 72 - 103, Add a new test in
provider-detail.test.tsx that covers the regression where an empty runtime links
array should override non-empty manifest links: render ProviderDetailPage with
plugin.meta.links containing at least one link and plugin.data.links set to an
empty array (and other fields similar to existing cases), then assert that no
quick link button from meta.links is rendered (e.g., expect queryByRole/button
for meta link to be null) to lock in the override behavior; reference the
existing test "prefers runtime quick links when plugin data provides them" as a
template and reuse its render props and assertions style for consistency.
🤖 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 `@src/pages/provider-detail.tsx`:
- Line 34: The links prop fallback incorrectly checks plugin.data?.links?.length
so an intentionally empty runtime array falls back to plugin.meta.links; update
the conditional in the links prop (the expression using
plugin.data?.links?.length) to prefer an explicitly provided runtime value even
if empty by using a null/undefined check (e.g., use nullish coalescing or test
plugin.data?.links !== undefined) so that when plugin.data.links is present but
empty it is used instead of plugin.meta.links.

---

Nitpick comments:
In `@src/pages/provider-detail.test.tsx`:
- Around line 72-103: Add a new test in provider-detail.test.tsx that covers the
regression where an empty runtime links array should override non-empty manifest
links: render ProviderDetailPage with plugin.meta.links containing at least one
link and plugin.data.links set to an empty array (and other fields similar to
existing cases), then assert that no quick link button from meta.links is
rendered (e.g., expect queryByRole/button for meta link to be null) to lock in
the override behavior; reference the existing test "prefers runtime quick links
when plugin data provides them" as a template and reuse its render props and
assertions style for consistency.
🪄 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: 31b24dec-e545-4efc-b6b2-e5ef72430a4e

📥 Commits

Reviewing files that changed from the base of the PR and between 8a5b337 and eabeb9a.

⛔ Files ignored due to path filters (1)
  • plugins/zed/icon.svg is excluded by !**/*.svg
📒 Files selected for processing (14)
  • README.md
  • docs/plugins/api.md
  • docs/plugins/schema.md
  • docs/providers/zed.md
  • plugins/test-helpers.js
  • plugins/zed/plugin.js
  • plugins/zed/plugin.json
  • plugins/zed/plugin.test.js
  • src-tauri/src/local_http_api/cache.rs
  • src-tauri/src/plugin_engine/host_api.rs
  • src-tauri/src/plugin_engine/runtime.rs
  • src/lib/plugin-types.ts
  • src/pages/provider-detail.test.tsx
  • src/pages/provider-detail.tsx
👮 Files not reviewed due to content moderation or server errors (7)
  • src-tauri/src/plugin_engine/runtime.rs
  • src-tauri/src/plugin_engine/host_api.rs
  • docs/plugins/api.md
  • plugins/zed/plugin.js
  • plugins/zed/plugin.json
  • docs/providers/zed.md
  • README.md

Comment thread src/pages/provider-detail.tsx Outdated
@validatedev
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbf73f45a7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

name={plugin.meta.name}
plan={plugin.data?.plan}
links={plugin.meta.links}
links={plugin.data?.links ?? plugin.meta.links}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve manifest links when probes omit runtime links

When a probe succeeds for any plugin that does not return runtime links, Rust still serializes output.links as an empty array (PluginOutput.links is a Vec and parse_links returns Vec::new() when absent). This makes plugin.data?.links truthy here, so existing manifest quick links for providers like Codex/Cursor are hidden after the first probe instead of falling back to plugin.meta.links. Use runtime links only when the probe actually provided them, or make the field optional end-to-end.

Useful? React with 👍 / 👎.

@rohithgoud30
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72d037e7c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/zed/icon.svg Outdated
@rohithgoud30
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02edcfcdcf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/zed/plugin.js
function probe(ctx) {
const credentials = loadCredentials(ctx)

const clientUser = requestJson(ctx, credentials, USER_URL, { soft: false })
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Redact Zed user fields before logging responses

When this request succeeds, the host HTTP wrapper logs a response preview, and the Zed /client/users/me response shown in the new tests/docs includes account identifiers like github_login and default_organization_id. The current redaction list covers keys like login/org_id, but not these Zed-specific snake_case fields, so normal successful probes can write user/org identifiers to app logs. Add these response keys to the host redaction list with a regression test, or avoid logging this endpoint body.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why does it address one issue at a time instead of all at once?

@rohithgoud30
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core docs plugin rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants