Skip to content

feat: openai auth login via cli#217

Merged
NanmiCoder merged 7 commits intoNanmiCoder:mainfrom
cynicalight:main
May 4, 2026
Merged

feat: openai auth login via cli#217
NanmiCoder merged 7 commits intoNanmiCoder:mainfrom
cynicalight:main

Conversation

@cynicalight
Copy link
Copy Markdown
Contributor

在 TUI 新增了 openai auth 登录,可以直接使用 openai 的订阅。

  1. TUI /login 新增了 openai 登录的选项
  2. 认证成功后,使用 /model 会显示为 openai 的模型

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels Apr 29, 2026
@cynicalight
Copy link
Copy Markdown
Contributor Author

openai auth login:
image

model selection:
image

@cynicalight
Copy link
Copy Markdown
Contributor Author

@claude review

@NanmiCoder
Copy link
Copy Markdown
Owner

首先 非常感谢你的贡献,这个改动比较大,影响范围不太好评估,加上openai oauth一直是我想弄但是没时间弄,这边建议把把桌面端的oauth也加上,可以参考claude的oauth

另外建议拉取最新的main的代码,加了很多测试和质量门禁的,pr前让ai跑下项目里质量门禁,这样后面返修的概率小一些

(最近一直更新这个repo发现,虽然ai写代码真的非常快,但是全局视野还是差了一些,会有概率改着改着把别的功能就改废了,所以E2E、冒烟测试这些比较重要)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

PR quality triage

Changed areas: area:cli-core, area:desktop, area:server

CLI core policy: No CLI-core policy block detected.

CLI core files:

  • src/commands/login/login.tsx
  • src/components/OpenAILoginFlow.tsx
  • src/components/SlashLoginFlow.tsx
  • src/utils/__tests__/tokens.test.ts
  • src/utils/auth.ts
  • src/utils/context.ts
  • src/utils/model/model.ts
  • src/utils/model/modelOptions.ts
  • src/utils/model/validateModel.ts
  • src/utils/status.tsx
  • src/utils/tokens.ts

Expected checks:

  • change-policy
  • desktop-checks
  • server-checks
  • desktop-native-checks

Test coverage signals:

  • Desktop product files changed without a desktop test file in the PR.
  • Agent/model runtime path changed: use mock/request-shape tests in PR and maintainer live-model smoke before release.

Risk notes:

  • No special risk notes from changed paths.

Hard merge gates still come from GitHub Actions, not AI review.

Dosu handoff: Dosu can be used as the AI reviewer for risk explanation, missing-test prompts, and maintainer Q&A. If it does not comment automatically from the PR template, ask:

@dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact.

@cynicalight
Copy link
Copy Markdown
Contributor Author

ai summary 了一下新补充的测试情况:

新增 18 个测试用例全部通过:

  • HahaOpenAIOAuthService 单测 12 个:文件存储读写、session 管理、token
    过期/刷新/刷新失败
  • REST API 集成测试 6 个:/start、状态查询、logout、token 不泄露到响应体

已有测试回归情况:

  • 全部已有 OAuth 相关测试(haha-oauth-service、haha-oauth-api)通过,无回归
  • check:server 整体 442 pass,2 fail —— 两个失败都在 settings.test.ts
    里,是已有「OpenAI OAuth model merge + env
    provider」那两个用例,跟本次改动无关,属于 history issue

PR quality gate:

  • 因为改到了 src/server/router.ts 和
    src/server/index.ts,质量门禁按策略判定为 CLI core 变更,需要 maintainer
    审批后 ALLOW_CLI_CORE_CHANGE=1 才能通过 —— 这个行为是预期内的

那两个已有的失败用例建议在别的问题/PR里修,跟本次改动完全无关。

@NanmiCoder NanmiCoder added the allow-cli-core-change Maintainer override for CLI core changes label May 4, 2026
PR 217 combined OpenAI OAuth model options with env-configured provider models, but the picker path returned before appending third-party model aliases. The desktop workspace test also exercised Prism highlighting for every expanded line, which was costly enough to time out on CI runners. The docs job did not need the root React Vite plugin; the desktop package owns that dependency.\n\nConstraint: PR Quality must pass server, desktop, and docs jobs before merge.\nRejected: Increase Vitest timeout | keeps the expensive render path and hides the CI regression.\nRejected: Add root Vite 8 peer dependencies | root only builds VitePress docs; React Vite plugin belongs in desktop/.\nConfidence: high\nScope-risk: narrow\nTested: npm ci --ignore-scripts; npm run docs:build; bun test src/server/__tests__/settings.test.ts src/server/__tests__/conversation-service.test.ts; bun run check:server; bun run check:desktop\nNot-tested: live provider OAuth login
@github-actions github-actions Bot removed the area:docs label May 4, 2026
@NanmiCoder NanmiCoder merged commit 1becbe3 into NanmiCoder:main May 4, 2026
5 of 7 checks passed
NanmiCoder added a commit that referenced this pull request May 5, 2026
Remote main already contains PR #217. Local main had provider context-window and auth-strategy work, so this merge keeps both context resolvers and reconciles the desktop Bun lockfile with the merged desktop package manifest. The accidental remote .nvimlog artifact is excluded from the merge result.

Constraint: Local main was 15 commits ahead and 8 commits behind origin/main after PR #217 was merged remotely
Rejected: Fast-forward pull | local main had unpushed commits
Rejected: Keep remote desktop lockfile verbatim | failed bun install --frozen-lockfile against the merged package.json
Confidence: high
Scope-risk: broad
Directive: Keep provider-configured context windows ahead of OpenAI OAuth model windows so explicit user/provider settings win
Tested: bun install --frozen-lockfile; cd desktop && bun install --frozen-lockfile; git diff --check; bun run check:server; bun run check:desktop; ALLOW_CLI_CORE_CHANGE=1 bun run quality:pr
Not-tested: live provider OAuth login with a real OpenAI account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-cli-core-change Maintainer override for CLI core changes area:cli-core area:desktop area:server enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants