-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feat(onboarding): first-run experience for third-party providers #1864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kevincodex1
merged 5 commits into
Gitlawb:main
from
kevincodex1:ui/third-party-onboarding
Jul 20, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8a0b449
feat(onboarding): first-run experience for third-party providers
kevincodex1 1227275
fix(onboarding): address review — testable gating seam + env-profile …
kevincodex1 4096016
fix(onboarding): refresh reused profile credentials + accurate env va…
kevincodex1 2d23d56
fix(onboarding): preserve profile fields and verify the credential re…
kevincodex1 a00a29e
fix(onboarding): redact credential-bearing endpoints before display
kevincodex1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { describe, expect, test } from 'bun:test' | ||
|
|
||
| import { getEnvProviderOption } from './envProviderOption.js' | ||
|
|
||
| // Secret-disclosure regression coverage: OPENAI_BASE_URL / OPENAI_API_BASE | ||
| // are credential-bearing in the wild, and everything the onboarding option | ||
| // renders lands in terminal scrollback. displayBaseUrl must never carry the | ||
| // secret; baseUrl must stay intact so the saved profile still works. | ||
|
|
||
| describe('getEnvProviderOption — credential redaction', () => { | ||
| test('URL userinfo is redacted for display but preserved for the profile', () => { | ||
| const raw = 'https://svc-user:sup3r-s3cret@api.example.com/v1' | ||
| const option = getEnvProviderOption({ | ||
| OPENAI_BASE_URL: raw, | ||
| OPENAI_MODEL: 'gpt-4o', | ||
| }) | ||
|
|
||
| expect(option.displayBaseUrl).not.toContain('sup3r-s3cret') | ||
| expect(option.displayBaseUrl).not.toContain('svc-user') | ||
| expect(option.displayBaseUrl).toContain('api.example.com') | ||
| // The working URL is untouched — the profile must still authenticate. | ||
| expect(option.baseUrl).toBe(raw) | ||
| expect(option.available).toBe(true) | ||
| }) | ||
|
|
||
| test('sensitive query parameters are redacted for display', () => { | ||
| const raw = 'https://api.example.com/v1?token=abcd1234secret&api_key=zzz9999' | ||
| const option = getEnvProviderOption({ | ||
| OPENAI_BASE_URL: raw, | ||
| OPENAI_MODEL: 'gpt-4o', | ||
| }) | ||
|
|
||
| expect(option.displayBaseUrl).not.toContain('abcd1234secret') | ||
| expect(option.displayBaseUrl).not.toContain('zzz9999') | ||
| expect(option.displayBaseUrl).toContain('api.example.com') | ||
| expect(option.baseUrl).toBe(raw) | ||
| }) | ||
|
|
||
| test('a credential-bearing OPENAI_API_BASE is redacted and named correctly', () => { | ||
| const raw = 'https://user:pass@gateway.internal:8443/v1' | ||
| const option = getEnvProviderOption({ | ||
| OPENAI_API_BASE: raw, | ||
| OPENAI_MODEL: 'llama3', | ||
| }) | ||
|
|
||
| expect(option.varName).toBe('OPENAI_API_BASE') | ||
| expect(option.displayBaseUrl).not.toContain('pass') | ||
| expect(option.baseUrl).toBe(raw) | ||
| }) | ||
|
|
||
| test('a plain endpoint passes through unchanged', () => { | ||
| const option = getEnvProviderOption({ | ||
| OPENAI_BASE_URL: 'http://localhost:11434/v1', | ||
| OPENAI_MODEL: 'llama3', | ||
| }) | ||
| expect(option.displayBaseUrl).toContain('localhost:11434') | ||
| expect(option.varName).toBe('OPENAI_BASE_URL') | ||
| }) | ||
|
|
||
| test('a malformed endpoint still does not leak userinfo', () => { | ||
| // redactUrlForDisplay has a non-URL fallback path; the option must not | ||
| // regress to echoing the raw string when parsing fails. | ||
| const option = getEnvProviderOption({ | ||
| OPENAI_BASE_URL: 'not a url://user:secret-pw@host/v1', | ||
| OPENAI_MODEL: 'gpt-4o', | ||
| }) | ||
| expect(option.displayBaseUrl).not.toContain('secret-pw') | ||
| }) | ||
| }) | ||
|
|
||
| describe('getEnvProviderOption — availability and var naming', () => { | ||
| test('OPENAI_BASE_URL wins over OPENAI_API_BASE and is named as such', () => { | ||
| const option = getEnvProviderOption({ | ||
| OPENAI_BASE_URL: 'https://primary.example.com/v1', | ||
| OPENAI_API_BASE: 'https://fallback.example.com/v1', | ||
| OPENAI_MODEL: 'gpt-4o', | ||
| }) | ||
| expect(option.baseUrl).toBe('https://primary.example.com/v1') | ||
| expect(option.varName).toBe('OPENAI_BASE_URL') | ||
| }) | ||
|
|
||
| test('a profile needs both a base URL and a model', () => { | ||
| expect( | ||
| getEnvProviderOption({ OPENAI_BASE_URL: 'https://x.example/v1' }).available, | ||
| ).toBe(false) | ||
| expect(getEnvProviderOption({ OPENAI_MODEL: 'gpt-4o' }).available).toBe(false) | ||
| expect(getEnvProviderOption({}).available).toBe(false) | ||
| }) | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { redactUrlForDisplay } from './redaction.js' | ||
|
|
||
| /** | ||
| * Derivation for the "use current environment configuration" onboarding | ||
| * option (ConsoleOAuthFlow), extracted as a pure seam so the | ||
| * secret-disclosure boundary is regression-tested directly rather than | ||
| * asserted against component source text. | ||
| * | ||
| * The split between `baseUrl` and `displayBaseUrl` is load-bearing: | ||
| * OPENAI_BASE_URL / OPENAI_API_BASE are credential-bearing in the wild | ||
| * (userinfo like https://user:pass@host/v1, or ?token=/?api_key= query | ||
| * params). Anything rendered lands in terminal scrollback, so ONLY | ||
| * `displayBaseUrl` may reach the UI; `baseUrl` keeps the working URL for | ||
| * profile creation/activation. | ||
| */ | ||
| export type EnvProviderOption = { | ||
| /** True when both a base URL and a model are present (a profile needs both). */ | ||
| available: boolean | ||
| /** The env var the base URL actually came from, for accurate troubleshooting. */ | ||
| varName: 'OPENAI_BASE_URL' | 'OPENAI_API_BASE' | ||
| /** Raw endpoint — for profile persistence/activation only, never rendered. */ | ||
| baseUrl: string | undefined | ||
| /** Redacted endpoint — the only form safe to render. */ | ||
| displayBaseUrl: string | undefined | ||
| model: string | undefined | ||
| } | ||
|
|
||
| export function getEnvProviderOption( | ||
| processEnv: NodeJS.ProcessEnv = process.env, | ||
| ): EnvProviderOption { | ||
| const baseUrl = processEnv.OPENAI_BASE_URL ?? processEnv.OPENAI_API_BASE | ||
| const model = processEnv.OPENAI_MODEL | ||
| return { | ||
| available: Boolean(baseUrl && model), | ||
| varName: processEnv.OPENAI_BASE_URL ? 'OPENAI_BASE_URL' : 'OPENAI_API_BASE', | ||
| baseUrl, | ||
| displayBaseUrl: baseUrl ? redactUrlForDisplay(baseUrl) : baseUrl, | ||
| model, | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.