Skip to content

Add auth source labels and debug summary#55

Merged
kargnas merged 13 commits intomainfrom
codex/auth-source-labels
Feb 4, 2026
Merged

Add auth source labels and debug summary#55
kargnas merged 13 commits intomainfrom
codex/auth-source-labels

Conversation

@kargnas
Copy link
Member

@kargnas kargnas commented Feb 4, 2026

Summary

  • Show auth source labels for multi-account providers only when sources differ
  • Rename Codex label to ChatGPT in quota menu
  • Add detailed auth discovery summary to error debug output without exposing sensitive data

Testing

  • xcodebuild clean build

@op-gg-ai-devops
Copy link
Contributor

인증 소스(키체인, 설정 파일 등) 레이블링 추가하고, 다계정 지원 로직 개선하면서 TokenManager 디버그 서머리 기능까지 야무지게 챙겼네.


TokenManager가 이제 VS Code 설정 파일부터 키체인까지 싹 다 뒤지네. 확장성 좋아진 건 인정하는데, 파일 시스템 접근할 때 권한 문제나 예외 처리는 꼼꼼하게 했냐?
각 Provider 파일마다 dedupeCandidatessourcePriority 로직이 너무 복붙 느낌이다. 나중에 ProviderProtocol 익스텐션 같은 걸로 공통화 좀 하자. 코드 중복 보면 알러지 안 생기냐?
그래도 디버그 서머리에 인증 소스 상태(FOUND/MISSING)를 한눈에 보여주는 건 아주 칭찬한다. 이제 유저가 "왜 안 돼요?" 징징거릴 때 로그만 까보면 바로 답 나오겠네.


This is just a preview.
For a detailed, line-by-line code review (including bug detection and security checks), please write a comment like @opgginc/op-gg-ai-devops please review this, or add @opgginc/op-gg-ai-devops team as a Reviewer.

@kargnas kargnas requested a review from a team February 4, 2026 09:58
@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

Status Task Result
리포 상태 점검 및 make setup 실행 환경 세팅은 진작에 끝내놨으니까 걱정 마라.
PR 전체 diff와 CI 상태 분석 후 문제 식별 니가 수정한 거 다 뜯어보느라 고생 좀 했다. 문제점 다 찾았음.
리뷰 코멘트 및 요약 작성 후 gh api로 제출 리뷰 제출 끝냈다.

Copilot aggregate 계산 꼬이는 부분 짚었고 문서 보강 필요하다고 남겼다. 로컬 lint는 swiftlint 부재라 못 돌렸음.
Reviewed with openai/gpt-5.1-codex-max


📋 View Full Logs

Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

🤖 OP.GG DevOps AI Code Review

  • CI: ✅ (Lint/Build/Test/CI/CodeQL 모두 최근 커밋에서 통과).
  • Smoke: make lint 실패(swiftlint가 runner에 없어 실행 불가)로 추가 검사 못 돌렸음.

Findings

  • Copilot aggregate usage가 최저 remaining을 가진 계정과 다른 계정의 entitlement를 섞어서 계산함(CopilotMonitor/CopilotMonitor/Providers/CopilotProvider.swift:379). 계정별 limit가 다르면 전체 퍼센트가 왜곡됨. minRemaining을 준 계정의 entitlement를 함께 써서 일관된 비율이 나오도록 계산하는 게 안전함.
  • 문서 갱신 없음: 멀티 계정 표기/인증 소스 라벨 추가, auth discovery summary 출력 등이 README/AGENTS에 전혀 언급되지 않음. 새 데이터 경로/키체인 탐색 방법과 다계정 메뉴 노출 방식을 README 등에 추가해줘.

이 PR에 커밋이 더 push되면 전체 PR을 다시 리뷰함. PR 코멘트에서 @opgginc/op-gg-ai-devops 멘션해도 재리뷰함. 예) 1) @opgginc/op-gg-ai-devops Copilot aggregate 퍼센트 다시 봐줘 2) @opgginc/op-gg-ai-devops README에 auth source 라벨 설명 추가 검토 3) @opgginc/op-gg-ai-devops lint 실패 원인만 확인해줘

@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

Status Task Result
Initialize review plan and status Plan is ready, bro.
Analyze PR diff and repository context Checked your mess of a diff.
Check CI/CD status and environment variables CI is chill, no red flags.
Perform deep code review (logic, security, performance) Roasted your logic, dude.
Verify and update documentation (README, AGENTS.md, .env.example) Docs are fine, I guess.
Post review to GitHub Spilling the tea on GitHub now.
Update status comment to Completed Done, get to work.

멀티 계정 지원 기능이 추가되었지만, 계정별 순차적인 API 호출로 인한 성능 저하가 우려됩니다. 병렬 처리(TaskGroup)를 적용하여 성능을 개선하도록 수정 요청했습니다. 문서는 AGENTS.md에 관련 패턴을 업데이트했습니다.

Reviewed with google/gemini-3-pro-preview


📋 View Full Logs

Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

야, 멀티 계정 지원 기능 추가한 건 좋은데 성능 생각은 안 하냐?

계정 여러 개 등록해놓고 이렇게 순차적으로(for-loop) API 호출하면 사용자 속 터진다. 계정이 5개면 대기 시간도 5배 늘어나는 거야. 기본 아니냐?

핵심 수정 사항:

  • 모든 Provider(Claude, Codex, Gemini, Copilot)에서 계정별 Fetch 로직을 **병렬 처리(TaskGroup)**로 바꿔라.
  • AGENTS.md에 멀티 계정 처리 패턴 내가 업데이트 해놨으니까 참고하고.

CI는 통과했네. 운 좋은 줄 알아라.

@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

Status Task Result
git 설정 확인 및 PR 브랜치 체크아웃 완료
PR 디프 분석 (변경 파일, 목적) 완료
CopilotProvider.swift 분석 완료
GeminiCLIProvider.swift 분석 완료
TokenManager.swift 분석 완료
ProviderResult.swift (DetailedUsage) 분석 완료
SubscriptionSettings.swift 분석 완료
CI/CD 상태 및 로그 확인 완료
라이브러리 조사 (websearch) 스킵 (표준 라이브러리 위주)
심층 코드 리뷰 완료
문서 검증 (README, AGENTS, .env) 완료 (README 업데이트함)
Smoke test: Try to build/compile the project 취소 (환경 제약)
리뷰 코멘트 작성 및 등록 완료
상태 코멘트 완료 업데이트 완료

멀티 계정 지원과 TokenManager 리팩토링 검토 완료했습니다. 전반적으로 코드는 깔끔하지만, 고아 구독(Orphaned Subscription) 처리 로직에서 네트워크 에러나 비활성화 시 설정이 삭제될 위험이 있어 코멘트 남겼습니다. README.md 업데이트도 완료했습니다.

Reviewed with google/gemini-3-pro-preview


📋 View Full Logs

Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

🤖 OP.GG DevOps AI Code Review

야, 멀티 계정 지원이랑 토큰 매니저 리팩토링한거 잘 봤다. 꽤 빡세게 짰네? 로 인증 로직 몰아넣은 건 아주 칭찬해. 코드 깔끔해졌다.

근데 고아 구독(orphaned subscription) 처리하는 로직 좀 불안한데? 이거 사용자가 의도치 않게 설정 날려먹을 수 있을 것 같아서 코멘트 남김.

그리고 내가 에 이번에 추가된 멀티 계정 기능들 업데이트 해뒀으니까 확인해봐라.

⚠️ Critical Issue

  • Orphaned Subscription Logic: 네트워크 에러나거나 프로바이더 끄면 구독 설정이 고아로 처리됨.

나머지 코드는 전반적으로 훌륭함. CI도 통과했고.

@kargnas
Copy link
Member Author

kargnas commented Feb 4, 2026

@opgginc/op-gg-ai-devops 리뷰 부탁드립니다.

@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

상태 작업 결과
Fetch existing bot reviews/status comment and CI state 이미 있는 봇 리뷰랑 CI 상태 다 긁어왔다.
Inspect PR diff, check docs/env changes, evaluate risks PR 디프 다 뜯어보고 리스크 견적 다 냈다.
Run required commands (git diff validation, optional smoke test) and prepare review payload 커맨드 돌리고 리뷰 올렸다.

CI green; smoke test not run (macOS/Xcode-only target on this runner). Raised fixes for Copilot token quota handling and orphaned subscription detection (see review comments).

Reviewed with openai/gpt-5.1-codex-max


📋 View Full Logs

@kargnas
Copy link
Member Author

kargnas commented Feb 4, 2026

리뷰 피드백 응답

1. Copilot aggregate usage calculation (CopilotProvider.swift:379)

미수정 - 봇이 코드를 잘못 읽은 것으로 보입니다.

현재 코드:

let usageCandidates = accountResults.compactMap { result -> (remaining: Int, entitlement: Int)? in ... }
if let minCandidate = usageCandidates.min(by: { $0.remaining < $1.remaining }) {
    aggregateUsage = ProviderUsage.quotaBased(
        remaining: minCandidate.remaining,
        entitlement: minCandidate.entitlement,  // 동일 계정의 entitlement 사용
    )
}

minCandidate(remaining, entitlement) 튜플이고, 이 튜플은 동일한 계정에서 추출된 값입니다. 다른 계정의 entitlement와 섞이지 않습니다.

2. 문서 갱신

👍 동의 - README에 멀티 계정 기능과 auth source 라벨에 대한 설명을 추가하겠습니다. (별도 커밋 예정)


위 피드백 외의 코드 리뷰 스레드는 모두 응답 및 resolve 처리 완료했습니다.

Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

🤖 OP.GG DevOps AI Code Review

  • CI: ✅ (Lint/Build/Test/CI/CodeQL all green). Smoke test not run here (macOS/Xcode-only target on Linux runner).
  • Copilot token-only candidates with missing quota fields return 0 entitlement/0 remaining, so the menu shows a zeroed quota instead of surfacing an auth/quota failure.
  • Orphaned-subscription detection treats disabled providers as orphaned, so the new menu entry asks to delete plans for providers the user intentionally turned off.

…d providers

고아 구독(orphaned subscription) 감지 로직에서 disabled 또는 fetch 실패한 provider를
잘못 고아로 처리하는 문제 수정.

추가된 체크:
- isProviderEnabled(): 비활성화된 provider 제외
- providerResults.keys.contains(): fetch 실패한 provider 제외

이로써 네트워크 에러나 의도적 비활성화 시 사용자의 구독 설정이
잘못 고아로 표시되는 false positive 방지.

> Co-authored-by: opencode (Sisyphus, oMo) <no-reply@opencode.ai>
> Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
quota 데이터(limit/remaining)가 없거나 limit <= 0인 토큰 candidate를
nil로 반환하여 aggregate 계산에서 제외.

이전에는 0/0 usage를 생성하여 aggregate가 0%로 떨어지는 문제가 있었음.
이제 유효한 quota 데이터가 있는 계정만 aggregate에 포함됨.

> Co-authored-by: opencode (Sisyphus, oMo) <no-reply@opencode.ai>
> Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@kargnas
Copy link
Member Author

kargnas commented Feb 4, 2026

@opgginc/op-gg-ai-devops

@opgginc opgginc deleted a comment from op-gg-ai-devops bot Feb 4, 2026
@opgginc opgginc deleted a comment from op-gg-ai-devops bot Feb 4, 2026
@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

Review completed and posted on the PR.
Docs update was pushed to the branch.
Smoke test could not run because xcodebuild is unavailable on this runner.

상태 작업 내용 결과
필요한 셋업 돌리고 PR 메타데이터(diff, 커밋, CI 상태, 이전 봇 리뷰) 수집 데이터 싹 다 긁어왔다
문서/의존성 조사 및 스모크 테스트와 함께 코드 변경점 철저히 리뷰 리뷰 끝
GitHub 리뷰 게시 및 상태 코멘트 업데이트 완료

Reviewed with openai/gpt-5.2-codex


📋 View Full Logs

Co-authored-by: Sangrak Choi <kars@kargn.as>
Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

🤖 OP.GG DevOps AI Code Review

  • CI: ✅ (Lint/Build/Test/CI/CodeQL all green for the latest runs).
  • Smoke: xcodebuild not available on this runner, so build/run could not be executed.
  • Research: websearch MCP failed with HTTP 402, so no external references were captured.

Docs Update Applied

  • README.md: Added bullets for auth source labels and orphaned plan cleanup. (commit 9281af8)

Findings

  1. Orphaned subscription cleanup should skip unknown provider keys to avoid deleting data for future/unsupported providers.
  2. Copilot remaining quota can go negative on overage; clamp to zero to avoid negative remaining in UI/percent calculations.
  3. Candidate dedupe by usage can collapse distinct accounts that happen to share identical usage at reset boundaries.

Notes

  • I did not add any new secrets or env vars.

- Clamp remaining to 0 when in overage to prevent negative display
- Skip unknown provider prefixes in orphan detection to avoid false positives

Co-authored-by: opencode (Sisyphus, oMo) <no-reply@opencode.ai>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@kargnas
Copy link
Member Author

kargnas commented Feb 4, 2026

@opgginc/op-gg-ai-devops 새 커밋 추가됨 - clamp negative remaining + skip unknown provider keys 수정 확인 부탁드립니다.

@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

Summary:
The PR implements multi-account support for Claude/Codex and orphaned plan cleanup robustly, but lacks critical tests for the new logic. A duplicate readability check in TokenManager.swift was identified.

  • Fetch and analyze git diff for PR Add auth source labels and debug summary #55
  • Identify changed files and potential impact
  • Check for dependency updates and research new libraries if any
  • Run smoke test (build/compile) to verify stability
  • Review code for bugs, security, performance, and style violations
  • Verify and update documentation (README.md, AGENTS.md, .env.example) if needed
  • Draft review summary and inline comments
  • Post review using gh api
  • Update status comment to Completed

Reviewed with google/gemini-3-pro-preview


📋 View Full Logs

Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

🤖 OP.GG DevOps AI Code Review

Summary

This PR introduces multi-account support for Claude and Codex providers, similar to the existing Gemini CLI implementation. It also adds a robust mechanism to detect and clean up "orphaned" subscription settings that no longer match any active provider/account. The CandidateDedupe helper is a great addition to reduce code duplication.

Key Improvements

  • Multi-account Support: Claude and Codex now correctly handle multiple accounts from different sources (OpenCode, local config, keychain).
  • Orphaned Plan Cleanup: Prevents stale subscription data from accumulating, with a user-friendly confirmation dialog.
  • Refactoring: CandidateDedupe simplifies the deduplication logic across providers.

⚠️ Critical Issues

  • Missing Tests: The core logic changes in fetch() (iterating accounts, error handling, deduplication) are completely untested. The existing tests only cover JSON decoding. I strongly recommend adding unit tests for CandidateDedupe at a minimum, and ideally integration tests for the fetch() flows if possible.

CI/CD Status

  • Checks: CI checks are not visible to me in this environment, but since Tests were not updated, please ensure xcodebuild test passes locally.

Suggestions

  • Consider adding a unit test for CandidateDedupe to ensure the priority and deduplication logic works as expected for edge cases (e.g., same usage but different IDs).

Other than the missing tests, the code quality is high and follows the project conventions.

중복된 isReadableFile guard 체크 제거 (338-345 라인).
원래 Gemini OAuth 용으로 추가했다가 일반화하면서 중복이 생겼음.

Co-authored-by: opencode (Sisyphus, oMo) <no-reply@opencode.ai>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@kargnas
Copy link
Member Author

kargnas commented Feb 4, 2026

@opgginc/op-gg-ai-devops 리뷰 부탁드립니다.

Round 3 Changes (74fbb63):

  • ✅ Removed duplicate isReadableFile check in TokenManager.swift
  • 🤦‍♂️ Declined unit test request for CandidateDedupe.merge (scope creep)

@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

❌ AI Code Review Cancelled

Newer commit detected or workflow was manually cancelled.


📋 View Logs | 🤖 Model: google/gemini-3-pro-preview

@op-gg-ai-devops
Copy link
Contributor

op-gg-ai-devops bot commented Feb 4, 2026

✅ AI Code Review Completed

멀티 계정 지원 및 고아 구독 정리 기능 구현, 공통 로직 리팩토링 확인 완료. 문서화 상태 양호하며 코드 품질 우수함.

상태 작업 내용 결과
PR 변경사항 확인 및 분석 (git diff, 파일 구조 파악) 완료
CI/CD 상태 확인 및 로그 분석 완료
관련 문서(README, AGENTS.md, .env.example) 최신화 여부 확인 및 수정 완료
코드 품질, 버그, 보안, 스타일 검토 (AGENTS.md 기준) 완료
리뷰 작성 및 게시 (gh api) 완료
리뷰 상태 업데이트 (완료 메시지) 완료

Reviewed with google/gemini-3-pro-preview


📋 View Full Logs

Copy link
Contributor

@op-gg-ai-devops op-gg-ai-devops bot left a comment

Choose a reason for hiding this comment

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

🤖 OP.GG DevOps AI Code Review

야, PR 봤다. 멀티 계정 지원이랑 고아 구독 정리 기능 추가했네.
CandidateDedupe로 중복 로직 깔끔하게 제네릭으로 뺀 거 아주 👍 칭찬해. TokenManager에 파일 읽기 전 isReadableFile 체크 넣은 것도 좋고. 문서도 다 업데이트 되어 있어서 딱히 깔 게 없네.

CI/CD는 아직 돌고 있는데 Lint 통과했으니 괜찮을 듯. 하나만 제안하고 넘어간다.

Comment on lines +496 to +505
private func orphanedIcon() -> NSImage? {
let symbol = NSImage(systemSymbolName: "exclamationmark.triangle.fill", accessibilityDescription: "Orphaned")
let sizeConfig = NSImage.SymbolConfiguration(pointSize: MenuDesignToken.Dimension.iconSize, weight: .regular)
let colorConfig = NSImage.SymbolConfiguration(hierarchicalColor: NSColor.systemOrange)
let config = sizeConfig.applying(colorConfig)
let image = symbol?.withSymbolConfiguration(config)
image?.isTemplate = false
return image
}

Copy link
Contributor

Choose a reason for hiding this comment

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

이거 orphanedIcon 호출될 때마다 NSImage 새로 만드는데, static으로 한 번만 만들어서 재사용하는 게 좋지 않겠냐? 뭐 엄청 큰 성능 차이는 아니겠지만.

Suggested change
private func orphanedIcon() -> NSImage? {
let symbol = NSImage(systemSymbolName: "exclamationmark.triangle.fill", accessibilityDescription: "Orphaned")
let sizeConfig = NSImage.SymbolConfiguration(pointSize: MenuDesignToken.Dimension.iconSize, weight: .regular)
let colorConfig = NSImage.SymbolConfiguration(hierarchicalColor: NSColor.systemOrange)
let config = sizeConfig.applying(colorConfig)
let image = symbol?.withSymbolConfiguration(config)
image?.isTemplate = false
return image
}
private static let orphanedIconImage: NSImage? = {
let symbol = NSImage(systemSymbolName: "exclamationmark.triangle.fill", accessibilityDescription: "Orphaned")
let sizeConfig = NSImage.SymbolConfiguration(pointSize: MenuDesignToken.Dimension.iconSize, weight: .regular)
let colorConfig = NSImage.SymbolConfiguration(hierarchicalColor: NSColor.systemOrange)
let config = sizeConfig.applying(colorConfig)
let image = symbol?.withSymbolConfiguration(config)
image?.isTemplate = false
return image
}()
private func orphanedIcon() -> NSImage? {
return Self.orphanedIconImage
}

@kargnas kargnas merged commit 3817055 into main Feb 4, 2026
15 checks passed
@kargnas kargnas deleted the codex/auth-source-labels branch February 4, 2026 14:35
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