Skip to content

feat(copilot): count sessions from session-state when the export is off - #42

Merged
hamidi-dev merged 4 commits into
mainfrom
feat/copilot-session-state
Nov 3, 2026
Merged

hamidi-dev merged 4 commits into
mainfrom
feat/copilot-session-state

Conversation

@hamidi-dev

@hamidi-dev hamidi-dev commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Copilot sessions can now show saved usage totals and per-model costs when OpenTelemetry exports are unavailable. These totals include request counts but not per-call Turns.
    • When export data exists for a session, its usage is shown from that data without combining it with saved totals.
    • Copilot availability checks now recognize saved session data and clarify when per-call details are unavailable.
  • Documentation

    • Updated setup and troubleshooting guidance to explain Copilot session data, export configuration, and feature limitations.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 5362247 and 7d608ad.

Files selected for processing: 5
  • .github/workflows/ci.yml
  • docs/backends.md
  • docs/sources.md
  • src/opentab/stores/copilot.py
  • tests/test_stores_copilot.py
Walkthrough

Copilot now recognizes saved session-state logs and uses their runtime usage totals when a session has no exported calls. Exported sessions remain based on OpenTelemetry data. Saved totals contribute to accounting but do not provide conversation turns.

Changes: Copilot session accounting

Layer / File(s) Summary
Saved-session discovery and usage events
src/opentab/sources.py, src/opentab/stores/copilot_events.py, src/opentab/cli/doctor.py, tests/test_doctor.py, docs/sources.md, docs/troubleshooting.md
Source detection and diagnostics now recognize saved session-state logs. CopilotEvents lists sessions and summarizes start, shutdown, and checkpoint events. Documentation describes saved-session availability and export setup.
Fallback usage accounting
src/opentab/stores/copilot.py, tests/test_stores_copilot.py, src/opentab/stores/cached.py, docs/backends.md
CopilotStore converts saved per-agent, per-model usage into accounting totals. It applies only the checkpoint charge above the latest shutdown and excludes invalid numeric values. Cache version changes to 24.
Export precedence and session presentation
src/opentab/stores/copilot.py, tests/test_stores_copilot.py, docs/sources.md
Sessions with exported calls use export data alone. Synthetic saved totals do not appear in conversation timelines or provide turn support. Tests and documentation cover these distinctions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CopilotStore
  participant CopilotEvents
  participant SessionStateLogs
  CopilotStore->>CopilotEvents: List saved sessions
  CopilotEvents->>SessionStateLogs: Read session-state event logs
  CopilotStore->>CopilotEvents: Request usage summary for a session
  CopilotEvents-->>CopilotStore: Return latest start, shutdown, and checkpoint data
  CopilotStore->>CopilotStore: Fold totals only when the session has no exported calls
Loading

Possibly related PRs

Merge Risk: Moderate · previous review 53622

Saved-session accounting should handle malformed charge values before merging: one malformed log can prevent all Copilot sessions from loading. Availability messages and documentation also need corrections to accurately describe which saved sessions appear.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed 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 main change: counting Copilot sessions from session-state when export is disabled.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 28 functions across 7 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
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

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 42f9c3d and 5362247.

Files selected for processing: 10
  • docs/backends.md
  • docs/sources.md
  • docs/troubleshooting.md
  • src/opentab/cli/doctor.py
  • src/opentab/sources.py
  • src/opentab/stores/cached.py
  • src/opentab/stores/copilot.py
  • src/opentab/stores/copilot_events.py
  • tests/test_doctor.py
  • tests/test_stores_copilot.py

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

@coderabbitai coderabbitai Bot 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.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread docs/backends.md Resolved
Comment thread docs/sources.md Resolved
Comment thread docs/sources.md Resolved
Comment thread src/opentab/cli/doctor.py Resolved
Comment thread src/opentab/sources.py Resolved
Comment thread src/opentab/stores/copilot.py Resolved
@hamidi-dev
hamidi-dev merged commit 1dbffe9 into main Nov 3, 2026
7 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Nov 3, 2026
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.

1 participant