Skip to content

Write one bar.perk.available point per Reset Credit - #24

Merged
GordonBeeming merged 2 commits into
mainfrom
gb/feature/23-per-credit-perk-points
Oct 12, 2026
Merged

GordonBeeming merged 2 commits into
mainfrom
gb/feature/23-per-credit-perk-points

Conversation

@GordonBeeming

@GordonBeeming GordonBeeming commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

CodexBar wrote one bar.perk.available point for all Reset Credits, carrying only the earliest expiry. With three credits expiring 23 Oct, 30 Oct and 7 Nov, Bar UI only ever saw 23 Oct.

Each available credit now gets its own point: value 1, perk.kind = reset_credit, perk.id (the same ID as codex.reset_credit.id) and that credit's perk.expires_at. If the API caps the credit list below availableCount, the rest go into one point with no ID, so Bar UI's total still matches. With no credits, CodexBar still writes a single 0 point, so Bar UI sees them run out.

This follows the Telemetry Spec v1 §4.3 amendment in GordonBeeming/bar-ui#19.

Test plan

  • New tests failed on the old encoder (one point with the total) and pass now
  • swift test: 87 tests, 0 failures, and swift build --build-tests has no warnings
  • After merge and release, Bar UI's Perks section lists each credit with its own expiry

Closes #23

Summary by CodeRabbit

  • Telemetry
    • Available credits are now reported individually, with each credit’s ID and expiry time. When the reported count exceeds the listed credits, the remainder is recorded without credit IDs. If more credits are listed than the reported count, only those expiring soonest are included.
    • When no available credits are listed, telemetry reports a zero value.
  • Documentation
    • Updated telemetry guidance to describe the per-credit values and how they reflect the reported count.

A single point for all credits kept only the earliest expiry. Each
available credit now gets its own point with its perk.id and expiry, as
Telemetry Spec v1 asks when the tool identifies each Perk.
@GordonBeeming
GordonBeeming requested a balanced review from Copilot October 12, 2026 12:17
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 147d73bd-9ed4-4522-8ee1-330d382274cf

📥 Commits

Reviewing files that changed from the base of the PR and between 7fef03b and 521b35a.


📒 Files selected for processing (3)
  • Sources/CodexBarCore/OTLPTelemetryEncoder.swift
  • Tests/CodexBarCoreTests/BarTelemetryTests.swift
  • docs/telemetry.md

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



📝 Walkthrough

Walkthrough

The bar.perk.available gauge now emits one value-1 point per selected available credit, with its ID and expiry. It represents any unlisted count with an ID-less point and emits an ID-less zero point when no named points are emitted. Tests and documentation cover the updated behavior.

Changes

Reset-credit telemetry

Layer / File(s) Summary
Per-credit gauge encoding and coverage
Sources/CodexBarCore/OTLPTelemetryEncoder.swift, Tests/CodexBarCoreTests/BarTelemetryTests.swift, docs/telemetry.md
The encoder emits individual points for available credits, capped at the nonnegative reported count and ordered by expiry when capped. An ID-less point represents any remainder or a zero count with no named points. Tests check point values and attributes; documentation describes the gauge.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to 521b3

No actionable issue is established for this change; it is mergeable after normal checks. Bar UI display validation remains planned for after release.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: emitting one bar.perk.available point for each Reset Credit.
Linked Issues check Passed Issue #23 requires one bar.perk.available point per available Reset Credit, with value 1, perk.kind=reset_credit, the credit ID, and its expiry. The encoder now writes these points and caps name…
Out of Scope Changes check Passed The changed encoder implements issue #23. The test changes verify the new telemetry contract. The telemetry documentation updates describe the same contract. No unrelated changes are shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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 commented Oct 12, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Pull request base or head changed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI 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.

🟡 Changes recommended

Inconsistent API data can make the emitted gauge exceed the authoritative available count, and the telemetry documentation remains outdated.

2 open findings
What changed in this PR

Updates reset-credit telemetry so Bar UI can display each identified credit and expiry separately.

Changes:

  • Emits one gauge point per available credit.
  • Preserves totals with fallback and zero points.
  • Adds encoder coverage for these cases.
File Description
Sources/​CodexBarCore/​OTLPTelemetryEncoder.swift Encodes per-credit perk points.
Tests/​CodexBarCoreTests/​BarTelemetryTests.swift Tests detailed, capped, and empty credit lists.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/CodexBarCore/OTLPTelemetryEncoder.swift Outdated
Comment thread Sources/CodexBarCore/OTLPTelemetryEncoder.swift
If the list holds more available rows than availableCount, only that
many are written, soonest expiry first, so the points never add up past
the count. The telemetry doc now describes the per-credit gauge.
@GordonBeeming
GordonBeeming marked this pull request as ready for review October 12, 2026 12:23
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T12:26:49.996509Z 521b35a Manual request
🔒 Security Review ✅ Completed 2026-10-12T12:27:34.846443Z 521b35a Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 521b35a629

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 521b35a629

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@GordonBeeming
GordonBeeming merged commit b90272d into main Oct 12, 2026
3 checks passed
@GordonBeeming
GordonBeeming deleted the gb/feature/23-per-credit-perk-points branch October 12, 2026 12:27
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.

Write one bar.perk.available point per Reset Credit

2 participants