Add Wake to the commerce companion cards, and gate it on a token - #6799
Open
viktormarinho wants to merge 1 commit into
Open
Add Wake to the commerce companion cards, and gate it on a token#6799viktormarinho wants to merge 1 commit into
viktormarinho wants to merge 1 commit into
Conversation
…t on a token Wake was the one commerce platform with no entry in COMMERCE_COMPANION_MCPS. Without a curated entry buildCompanionCards falls back to itemsByName[bindingType], looking the registry item up by server_json.name — so the card depended on the published app name matching the binding id exactly, and got dropped entirely (`if (!item) continue`) whenever it didn't. resolveCandidate has the same coupling on connections.app_name. Matching by the curated registryAppId instead makes the card independent of that field. The second half matters more. isCompanionConfigured had no `case "wake"`, so Wake fell to `default: true` — a linked Wake connection with no credentials at all read as "connected", which is exactly what the satisfied/configured split exists to prevent. Wake mints STATIC tokens in the merchant's panel, so both live in configuration state, and the two gate different lanes independently (storefrontToken => catalog reads, apiToken => the admin order lane). Either one alone makes the connection useful, so the guard is an OR — mirroring the refine on the consumer side, where a catalog-only connection must leave the orders lane ineligible rather than failing it. Also adds the FALLBACK_COMPANION_REQUIREMENTS entry so the card survives a CD proxy 401, and getConnectedDetail so a configured card shows the account instead of a gear.
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.
Wake was the one commerce platform with no entry in
COMMERCE_COMPANION_MCPS. Two consequences, and the second is the one worth reviewing.1. The card could silently not exist
Without a curated entry,
buildCompanionCardsfalls back toitemsByName[req.bindingType]— looking the registry item up byserver_json->>'name'. So the card renders only if the published app name equals the binding id exactly; otherwiseif (!item) continuedrops it, and the merchant sees no Wake card at all with nothing in the UI to explain it.resolveCandidatehas the same coupling onconnections.app_name, so even a rendered card would have had nothing to pick.That is not hypothetical — an app published with its scope inside
server_json.name(<scope>/<name>rather than<name>) hits both. Matching by the curatedregistryAppIdmakes the card independent of that field.2. A Wake connection with no credentials read as "connected"
isCompanionConfiguredhad nocase "wake", so Wake fell through todefault: true— linked was treated as usable, which is exactly what thesatisfied/configuredsplit exists to prevent.Wake mints static tokens in the merchant's panel, so both live in configuration state (no
getAccessTokenlane), and the two gate different capabilities independently:storefrontToken→ catalog readsapiToken→ the admin order laneEither one alone makes the connection useful, so the guard is an
OR, not anAND. That mirrors the refine on the consumer side, where requiring both would make a catalog-only connection fail the orders lane instead of leaving it ineligible.Changes
companions.ts— curatedwakeentry (registryAppId, area, headline)companions-core.ts—wakeinFALLBACK_COMPANION_REQUIREMENTSso the card survives a CD proxy 401;case "wake"inisCompanionConfiguredand ingetConnectedDetail(shows the account instead of a gear once configured)companions-core.test.ts— 3 tests: either token alone configures, neither does notTest
bun test src/routes/commerce-onboarding/companions-core.test.ts→ 52 pass / 0 fail.Summary by cubic
Adds Wake to the commerce companion cards so it no longer silently disappears when the published app name doesn't match the binding id, and treats a Wake connection as configured only when it carries at least one of its two static tokens.
wakeentry withregistryAppIdto decouple the card from the app name.case "wake"toisCompanionConfiguredthat requires eitherstorefrontTokenorapiToken; previously it defaulted to true, misreading a linked-but-unconfigured connection as usable.wakeinFALLBACK_COMPANION_REQUIREMENTSand shows the account in the connected detail.Written for commit a8090d1. Summary will update on new commits.