feat(plugins): add Zed AI provider#558
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis 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. ChangesZed AI provider with linked infrastructure
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 }
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 }
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/pages/provider-detail.test.tsx (1)
72-103: ⚡ Quick winAdd a regression test for empty runtime links overriding manifest links.
Please add a case where
plugin.data.links = []andplugin.meta.linksis 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
⛔ Files ignored due to path filters (1)
plugins/zed/icon.svgis excluded by!**/*.svg
📒 Files selected for processing (14)
README.mddocs/plugins/api.mddocs/plugins/schema.mddocs/providers/zed.mdplugins/test-helpers.jsplugins/zed/plugin.jsplugins/zed/plugin.jsonplugins/zed/plugin.test.jssrc-tauri/src/local_http_api/cache.rssrc-tauri/src/plugin_engine/host_api.rssrc-tauri/src/plugin_engine/runtime.rssrc/lib/plugin-types.tssrc/pages/provider-detail.test.tsxsrc/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
|
@codex review |
There was a problem hiding this comment.
💡 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} |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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".
|
@codex review |
There was a problem hiding this comment.
💡 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".
| function probe(ctx) { | ||
| const credentials = loadCredentials(ctx) | ||
|
|
||
| const clientUser = requestJson(ctx, credentials, USER_URL, { soft: false }) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
Why does it address one issue at a time instead of all at once?
9d51abd to
81c60a4
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Description
Adds a Zed AI provider for OpenUsage.
The provider reads Zed app credentials from the macOS Internet Password item for
https://zed.dev, withZED_USER_ID/ZED_ACCESS_TOKENas 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
Testing
bun run buildand it succeededbun run test -- --runand all tests passcargo test --libgit diff --checkScreenshots
Checklist
mainbranchSummary by cubic
Adds a
zedprovider 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
zedplugin: Token Spend (progress/text), Edit Predictions (progress/text), Daily Spend chart, Updated timestamp, plan label, overdue invoice badge.links; the UI now prefers runtimelinksover manifest links.host.keychain.readInternetPassword(server, account?); whitelistedZED_USER_IDandZED_ACCESS_TOKEN. Docs updated for the keychain method, runtimelinks, and Zed’s hosted-model scope; provider docs added; tests included.Bug Fixes
links(no fallback to manifest).linksis omitted.currentColorfor proper theming.Written for commit 81c60a4. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation
Tests