Commit af685a7
committed
fix(github): resolve billing data caching and API call issues
**Problem:**
1. GitHub Copilot billing data not appearing in model picker
2. URLSession was returning cached responses without billing fields
3. API calls attempted before authentication configured
**Root Cause:**
URLSession cached earlier API responses (potentially from before
authentication was available). When refreshing model list, the cached
response was returned instead of making a fresh authenticated request.
**Solution:**
1. Disable URLSession caching for GitHub models API:
- Added .reloadIgnoringLocalAndRemoteCacheData cache policy
- Ensures fresh API calls with current authentication
2. Guard against unauthenticated API calls:
- Added hasGitHubCopilotAuthentication() check
- Skip capabilities fetch if no token/API key configured
- Prevents caching of error responses
3. Code quality improvements:
- Cleaned up verbose debug logging
- Fixed misleading log messages about billing availability
- Improved code comments
**Files Changed:**
- Sources/APIFramework/Providers.swift: Cache policy + auth check
- Sources/APIFramework/EndpointManager.swift: hasGitHubCopilotAuthentication()
- Sources/APIFramework/ModelListManager.swift: Guard API calls
**Testing:**
✅ Billing data displays correctly (claude-opus-4.5: 3x, opus-41: 10x)
✅ No API calls when not authenticated
✅ Build passes with no errors
✅ End-to-end flow verified
**Impact:**
- Model picker now shows cost multipliers for all GitHub Copilot models
- Prevents unnecessary API errors during startup
- More reliable billing data caching1 parent 0911974 commit af685a7
3 files changed
Lines changed: 49 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
| 131 | + | |
| 132 | + | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
139 | 143 | | |
140 | 144 | | |
141 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
718 | | - | |
| 718 | + | |
719 | 719 | | |
720 | | - | |
| 720 | + | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
724 | 724 | | |
725 | 725 | | |
726 | | - | |
| 726 | + | |
727 | 727 | | |
728 | 728 | | |
729 | | - | |
| 729 | + | |
730 | 730 | | |
731 | | - | |
| 731 | + | |
732 | 732 | | |
733 | 733 | | |
734 | | - | |
| 734 | + | |
735 | 735 | | |
736 | 736 | | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
737 | 749 | | |
738 | 750 | | |
739 | 751 | | |
| |||
758 | 770 | | |
759 | 771 | | |
760 | 772 | | |
| 773 | + | |
| 774 | + | |
761 | 775 | | |
762 | 776 | | |
763 | 777 | | |
| |||
776 | 790 | | |
777 | 791 | | |
778 | 792 | | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
779 | 800 | | |
780 | 801 | | |
781 | 802 | | |
| |||
0 commit comments