Repository navigation
feat(translation): support ChatGPT plan authentication - #222
Merged
Merged
Conversation
Use the published PySubtrans 1.7.4 OpenAI provider to translate with a ChatGPT subscription. Keep API key billing as the default and exclude upstream desktop sign-in actions from Model Profile settings. Add offline authentication administration with protected persistent storage, a stable deployment host identity, and host-preserving credential import for Docker. Reuse the Work-root lease to serialize management with the server and document the official local-login and SSH-transfer workflow. Preserve strict subtitle validation, update error-aware progress and resume coverage, and verify token refresh, credential isolation, and a Job completing through mocked streamed Responses inference.
Expose read-only local credential presence while the server owns its Work-root lease. Keep status reads network-free and non-mutating, distinguish unreadable storage from missing credentials, and return no account or credential details. Add localized ChatGPT Settings with a copyable local login command, remote Docker import guidance, recovery instructions, and manual status refresh. Link setup before plan selection and keep dynamic feedback below provider controls so mobile keyboard focus remains visible. Map recognized plan authentication failures to administrator sign-in guidance while preserving explicit plan mode and ordinary API-key behavior. Cover status read failures, credential isolation, model discovery, inference errors, production routing, and responsive layouts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Translate with an eligible ChatGPT subscription using PySubtrans's official OpenAI provider. Create an OpenAI Model Profile with
use_chatgpt_planenabled after authenticating; model discovery and Jobs then use the plan's allowance through the public Responses API. API key authentication remains the default, including when the server inheritsOPENAI_USE_CHATGPT_PLAN.cueweaver-chatgptadministration commands for initialization, local browser sign-in, credential import, local status, and sign-out/revocation.pysubtrans/chatgpt-auth.jsonwith0600permissions inside a0700directory. Profiles, Job records, checkpoints, and ordinary API responses contain no OAuth credentials.Authentication and Docker
OpenAI's OSS registration flow requires an HTTP callback on
127.0.0.1. In a remote Docker deployment, the browser's loopback address belongs to the browser computer. A normal Web redirect to the container would not implement that flow correctly.This PR follows OpenAI's self-hosted VM procedure: initialize the server's host identity, sign in locally using CueWeaver, securely transfer the protected credential file over SSH, and import it while preserving the server's own host ID. The server then owns refresh-token rotation. Management commands acquire the server's Work-root lease and require it to be stopped, preventing concurrent credential writes and refreshes.
CueWeaver has no built-in user authentication, so OAuth management stays in the administrator CLI. The Web API exposes read-only credential presence; it cannot start OAuth, import credentials, refresh or revoke tokens, sign out, or replace the account. The README includes local and remote setup commands, Model Profile configuration, volume persistence, sign-out/reset, and plan restrictions.
Web authentication UX
GET /api/chatgpt-auth/status, returning onlycredentials_present,not_configured, orunavailablewithCache-Control: no-store. It reads the deployment's credential file while the server runs, without taking another lease, writing files, refreshing tokens, or using the network. Missing, malformed, unreadable, and partially written files are handled without exposing credentials or account identifiers.use_chatgpt_plan. Preserve explicit plan selection when discovery fails. Recognized OAuth and inference HTTP 401 failures direct administrators to ChatGPT setup; unrelated provider failures retain their own feedback. If upstream model discovery hides the underlying exception type, show connectivity and account-access guidance without claiming that authorization has expired.Upgrade compatibility
warnings_as_errors=True, since upstream now separates warnings from errors.thinking_budgetand temperature settings.Verification
scripts/test-backend.sh: 491 passed, including credential persistence, host-preserving import, invalid/revoked sessions, read-only status during application operation, transient file failures, profile mode switching, inference authentication feedback, token refresh after restart, a mocked streamed Responses translation with checkpoint/resume, and a Job completing through the ChatGPT-plan path.scripts/test-frontend.sh: 200 passed, including status/loading/error states, manual refresh, command copying, setup discovery, explicit plan preservation, API-key profile regressions, and localization invariants.scripts/lint-backend.sh --check: passed, including Ruff, mypy, Vulture, dependency boundaries, and Markdown lint.scripts/lint-frontend.sh --check: passed, including formatting, ESLint, TypeScript, and production build. Vite reports the existing bundle-size advisory.scripts/test-e2e.sh: production Docker image built successfully; 55 passed in the normal phase, then 1 passed in the restart-recovery phase. Includes the real read-only status endpoint and ChatGPT Settings in desktop/mobile route and accessibility checks. The restart-only case is intentionally skipped in the normal phase.cueweaver-chatgpt initcommand succeeds with a writable Work root.OAuth network operations and inference are mocked in the new automated tests. No real ChatGPT credentials or subscription usage were used.
Limitations