chore: split credentials.tsx pure logic into credentials/ modules with tests - #612
Merged
Conversation
🦋 Changeset detectedLatest commit: 7345805 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
Refactor phase 3, following #611: this breaks the ~5,700-line
credentials.tsxfile into focused, individually testable modules undersrc/setup/credentials/, adds coverage for the extracted units, and fixes one setup-flow bug the new tests surfaced.credentials.tsxis now a thin composition root (30 lines): the setup wizard's state machine lives in auseInitSetuphook, its rendering in anInitSetupView, and its pure logic (routing, formatting, env persistence) in sibling modules with their own test files. The extraction is mechanical and behavior-neutral, with one intentional exception called out under Behavior change below, so reviews get smaller and regressions in the first-run setup surface get caught.Structure
credentials.tsxwent from ~5,744 lines to 30 (a composition root + public re-export shim). Its contents were extracted into:test/setup/credentials/mirrors this layout, so every extracted pure module has a sibling test. Theuse-init-setup.tscontroller is coverage-excluded (documented invitest.config.ts): it is a keyboard-drivenuseInputflow that unit tests cannot drive cleanly, and its extractable logic already lives in the tested modules above.Coverage
Both columns measured under the repo's
all: truevitest config.Behavior change
The optional LangSmith setup step no longer re-prompts after it has been declined.
needsCredentialSetupalready gated the step on the two-signalneedsLangSmithStep()(a recordedLANGCHAIN_TRACING_V2decision counts as answered), but the two entry-point routers —getInitialStepandgetNextStepAfterRegion— still used a naive!process.env.LANGSMITH_API_KEYcheck, so a user who declined LangSmith got sent back into the step whenever setup reopened for another reason. Both routers now useneedsLangSmithStep(), with a decision-table regression test covering both routers across all four env states.Testing
New unit tests for every extracted pure module plus the
onboarding.tsgaps above. All tests pass (2035/2035). Typecheck, lint, and build are clean.