Refactor plugins to use ctx.util helpers#54
Conversation
Refactor plugin HTTP, JSON, auth-refresh, and date parsing to use
|
There was a problem hiding this comment.
1 issue found across 17 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="plugins/cursor/plugin.js">
<violation number="1" location="plugins/cursor/plugin.js:200">
P2: Missing null check after `tryParseJson`. Unlike `JSON.parse`, `tryParseJson` returns `null` on failure. The next line accesses `plan.planInfo` without checking if `plan` is null, which would throw a TypeError on malformed JSON. Add a null guard to be consistent with other usages in this file.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Summary
ctx.utilAPI, update the claude/codex/cursor plugins and their tests to rely on the helpers, and deduplicate frontend plugin state/timer/settings logic.Testing
Note
Medium Risk
Medium risk because it changes the plugin runtime API surface (
ctx.util) and refactors auth refresh/retry + JSON parsing paths in multiple plugins; regressions would primarily affect plugin data fetching and token refresh behavior.Overview
Plugins now get a shared
ctx.utilAPI injected by the host (tryParseJson, request helpers, auth-status detection, retry-on-auth, date/expiry utilities), and the Claude/Codex/Cursor plugins are refactored to route JSON parsing, HTTP calls, token-expiry checks, and 401/403 refresh+retry logic through these helpers.Tests and frontend logic are deduped by introducing
plugins/test-helpers.jsfor shared plugin ctx mocks, adding a reusableuseNowTickerhook (now used byPanelFooterwithresetKey: autoUpdateNextAtand byProviderCardwithstopAfterMs), centralizingPluginDisplayStateinsrc/lib/plugin-types.ts, and moving settings option constants (AUTO_UPDATE_OPTIONS,THEME_OPTIONS) intosrc/lib/settings.ts. Two short spec docs capture the intent and API surface.Written by Cursor Bugbot for commit 380ca70. This will update automatically on new commits. Configure here.
Summary by cubic
Introduced a shared ctx.util helper API for plugins and refactored the Claude, Codex, and Cursor plugins (and tests) to use it. Also deduped frontend state, timer, and settings logic with no behavior changes expected.
Written for commit 380ca70. Summary will update on new commits.