Skip to content

fix(cloud-plan): a tier named like an Object prototype key reads Cloud again - #87

Open
zereight wants to merge 1 commit into
mainfrom
fix/cloud-plan-label-own-keys
Open

zereight wants to merge 1 commit into
mainfrom
fix/cloud-plan-label-own-keys

Conversation

@zereight

@zereight zereight commented Dec 2, 2026

Copy link
Copy Markdown
Owner

What changed

  • src/lib/cloud-plan.ts: cloudPlanLabel checks Object.hasOwn(PLAN_LABEL, tier) again, as upstream does. A tier the app does not know reads "Cloud", including one named like an Object.prototype key.
  • src/components/BotLimitPopup.tsx: drops its private copy of cloudPlanLabel, which had the same gap, and imports the one in cloud-plan.ts.

Why

cloudPlanLabel("constructor") and cloudPlanLabel("toString") returned Object.prototype functions instead of "Cloud". PLAN_LABEL[tier] ?? "Cloud" falls through to the prototype for those keys. CloudAccountSettings.test.ts checks exactly this ("names the verified tier… a tier newer than the app reads Cloud").

The tier comes from the Cloud account (CloudAccountSettings.tsx:147, settings/account-summary.ts:30), so this is the boundary where an unknown value is read. In BotLimitPopup the label is only shown after an in-app upgrade, which the fork's stubbed useUpgrade never reports (BotLimitPopup.tsx:50-52), so that copy is unreachable today (read from the code, not run). It goes because it was a second copy of the same decision with the same bug.

room-card.ts keeps its own correct copy; this PR leaves it alone.

How it was verified

macOS, Node 24.22.1 (the CI version). Before is main 8c67e9d. The script imports the real src/lib/cloud-plan.ts and prints cloudPlanLabel for each tier.

Before shows a function for constructor and toString and an object for __proto__; after shows "Cloud" for all three.

check Before (main 8c67e9d) After (this branch)
cloudPlanLabel for undefined, pro, team, constructor, toString, __proto__ Pro, Pro, Cloud, <function>, <function>, <object> Pro, Pro, Cloud, Cloud, Cloud, Cloud
pnpm exec vitest run src/components/BotLimitPopup.test.ts src/lib/plan-billing-removed.test.ts src/lib/room-card.test.ts Tests 7 failed | 41 passed (48) Tests 7 failed | 41 passed (48), the same 7
pnpm exec tsc -b — exit 0
oxlint src/lib/cloud-plan.ts src/components/BotLimitPopup.tsx — exit 0

The 7 BotLimitPopup failures expect the in-app upgrade that #2 removed. They fail the same way before and after this change and are fixed separately with the other tests for removed features.

CloudAccountSettings.test.ts's tier case still fails on main before it reaches the label: it renders the account card, which the sign-in stub shows as signed out (expected '<section …' to contain '>Pro<'). The tests-for-removed-features PR narrows that case to cloudPlanLabel itself and keeps the constructor and toString rows; with this PR it passes.

Not covered

  • The Settings account card on screen with a real Cloud account.
  • BotLimitPopup's upgraded title, unreachable as above.

Checklist

  • One cause, one PR: the lost own-key check only
  • Before / after evidence
  • No new tests, no workflow changes

…gain

Removing plan billing (#2, ead5fea) copied cloudPlanLabel into
BotLimitPopup without upstream's Object.hasOwn check, and the stub that
brought src/lib/cloud-plan.ts back has the same form, so "constructor"
or "toString" returned a function. Restore upstream's check and let
BotLimitPopup import the one copy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant