Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Enhance MetricLine with periodDurationMs for pace tracking
- Added periodDurationMs field to MetricLine in API and schema documentation.
- Updated progress line implementation to utilize the new periodDurationMs for pace tracking.
- Clarified documentation on how periodDurationMs interacts with resetsAt for usage metrics.

Co-authored-by: Cursor <cursoragent@cursor.com>
  • Loading branch information
robinebers and cursoragent committed Feb 5, 2026
commit 90aed4ef8370876b34e095a30ef087d21aed8c78
2 changes: 2 additions & 0 deletions docs/plugins/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ ctx.line.progress({
suffix?: string // Required when kind="count" (e.g. "credits")
},
resetsAt?: string | null, // Optional: ISO timestamp for when usage resets
periodDurationMs?: number, // Optional: period length in ms for pace tracking
color?: string, // Optional: hex color for progress bar
}): MetricLine
```
Expand All @@ -321,6 +322,7 @@ Notes:
- `used` may exceed `limit` (overages).
- For `format.kind: "percent"`, `limit` must be `100`.
- Prefer setting `resetsAt` (via `ctx.util.toIso(...)`) instead of putting reset info in other lines.
- `periodDurationMs`: when provided with `resetsAt`, enables the pace tracking indicator (shows if usage rate will exhaust quota before reset).

**Example:**

Expand Down
2 changes: 2 additions & 0 deletions docs/plugins/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ type MetricLine =
| { kind: "dollars" }
| { kind: "count"; suffix: string };
resetsAt?: string; // ISO timestamp
periodDurationMs?: number; // period length in ms for pace tracking
color?: string;
}
| { type: "badge"; label: string; text: string; color?: string; subtitle?: string }
Expand All @@ -155,6 +156,7 @@ type MetricLine =
- `color`: optional hex string (e.g. `#22c55e`)
- `subtitle`: optional text displayed below the line in smaller muted text
- `resetsAt`: optional ISO timestamp (UI shows "Resets in ..." automatically)
- `periodDurationMs`: optional period length in milliseconds (enables pace indicator when combined with `resetsAt`)

### Text Line

Expand Down
7 changes: 1 addition & 6 deletions plugins/codex/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,13 @@
if (reviewWindow) {
const used = reviewWindow.used_percent
if (typeof used === "number") {
// Use reset_after_seconds if available, otherwise fall back to session duration
var reviewPeriodMs = PERIOD_SESSION_MS
if (typeof reviewWindow.reset_after_seconds === "number") {
reviewPeriodMs = reviewWindow.reset_after_seconds * 1000
}
lines.push(ctx.line.progress({
label: "Reviews",
used: used,
limit: 100,
format: { kind: "percent" },
resetsAt: getResetsAtIso(ctx, nowSec, reviewWindow),
periodDurationMs: reviewPeriodMs
periodDurationMs: PERIOD_SESSION_MS
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Feb 5, 2026

Choose a reason for hiding this comment

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

P2: periodDurationMs is now hardcoded to PERIOD_SESSION_MS for Reviews, ignoring reset_after_seconds and potentially miscomputing pace when the review window length differs from 5 hours.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/codex/plugin.js, line 282:

<comment>periodDurationMs is now hardcoded to PERIOD_SESSION_MS for Reviews, ignoring reset_after_seconds and potentially miscomputing pace when the review window length differs from 5 hours.</comment>

<file context>
@@ -273,18 +273,13 @@
             format: { kind: "percent" },
             resetsAt: getResetsAtIso(ctx, nowSec, reviewWindow),
-            periodDurationMs: reviewPeriodMs
+            periodDurationMs: PERIOD_SESSION_MS
           }))
         }
</file context>
Suggested change
periodDurationMs: PERIOD_SESSION_MS
periodDurationMs: typeof reviewWindow.reset_after_seconds === "number"
? reviewWindow.reset_after_seconds * 1000
: PERIOD_SESSION_MS
Fix with Cubic

Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
}))
}
}
Expand Down