fix(pm-wizard): support stored credentials in edit mode#1153
Merged
zbigniewsobiecki merged 3 commits intodevfrom Apr 18, 2026
Merged
fix(pm-wizard): support stored credentials in edit mode#1153zbigniewsobiecki merged 3 commits intodevfrom
zbigniewsobiecki merged 3 commits intodevfrom
Conversation
buildEditState intentionally leaves raw API credentials blank when re-opening an existing integration (security), but the verify, create-label, and create-custom-field hooks required form-state credentials and threw "Missing credentials or team selection" client-side before reaching the backend. The discovery hooks already had the projectId fallback — now the mutation hooks do too. Introduces shouldUseStoredCredentials(state) in pm-wizard-state.ts as the single source of truth for "send projectId vs send credentials". Each hook (useVerification, useTrello/LinearLabelCreation, useTrello/JiraCustomFieldCreation) now picks the correct path. Team / board / project-key checks stay — those come from config state, not credentials, so their error messages are split out. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
The gate `(!state.isEditing || !state.hasStoredCredentials || credsReady)` hid the button precisely when it was most useful — editing an existing integration with stored credentials but an empty API-key field. User had no way to test that the stored key still works. Drop the gate. Enable the button whenever credentials are ready OR the user is editing with stored credentials (backend resolves them via projectId path). Add a muted "Using stored credentials" hint when taking the stored-creds path so it's obvious what's happening. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Eight new tests, one per (provider × scenario) combo. Fresh setup → false; edit with stored creds + empty API-key → true; edit with re-typed API-key → false; edit without stored creds → false. Locks in the #1152-follow-up contract that stored-creds-aware mutations route through projectId instead of throwing "Missing credentials". Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Two related bugs surface when a user re-opens an existing Linear/Trello/JIRA PM integration to tweak settings:
Root cause:
buildEditStateintentionally leaves raw API credentials blank when re-opening an integration (security —hasStoredCredentialsis flipped true instead). The discovery hooks (useTrelloBoards,useLinearStates, etc.) already had an edit-mode fallback: when stored creds exist and the API-key field is empty, passprojectIdand let the backend resolve credentials viaresolvePMCredentials. But the mutation hooks (useVerification,useTrelloLabelCreation,useLinearLabelCreation,useTrelloCustomFieldCreation,useJiraCustomFieldCreation) required form-state credentials and threw synchronously.This PR plumbs the same
projectIdfallback into every mutation hook. Zero backend change —pm.discovery.createLabel,createCustomField, anddiscoverall already accept an optionalprojectId.What changed
shouldUseStoredCredentials(state)helper inpm-wizard-state.ts. Single source of truth: "is this a stored-creds-path mutation". 8 unit tests.pm-wizard-hooks.tsupdated to consult the helper and branch between{ projectId }and{ credentials: ... }. Team / board / project-key checks stay (those come from config state, not creds).pm-wizard.tsx: drop the visibility gate on the Verify Connection button. Always render on the credentials step. Enable whencredsReady || (editing && stored). Show a muted "Using stored credentials" hint when taking the stored-creds path.createMissingLabelsMutationbodies to extract arunPerLabelCreationshelper (keeps them under the biome cognitive-complexity threshold).Test plan
npm test— 8210 / 8210 (8 new tests inpm-wizard-state.test.ts, the rest unchanged)npm run lint— cleannpm run typecheck— cleancd web && npm run build— clean🤖 Generated with Claude Code