Skip to content

feat(pool): 账号池只显示已绑定的渠道,没绑国际版就不再出现国际版卡 - #186

Open
tsddts wants to merge 1 commit into
XDTrees:mainfrom
tsddts:feat/region-cards-only-bound
Open

tsddts wants to merge 1 commit into
XDTrees:mainfrom
tsddts:feat/region-cards-only-bound

Conversation

@tsddts

@tsddts tsddts commented Nov 18, 2026

Copy link
Copy Markdown

问题

账号池首页无条件渲染两张 region 卡(国内版 + 国际版)。没绑国际版账号的用户每次打开都要面对一整张国际版卡:端点、模型数 0、以及一整套「怎么装 WorkBuddy AI、怎么注册国际版号」的引导。用户要求:绑定了哪个渠道,就显示什么渠道。

改法

src/client/region-card.tsx 新增 visibleRegionCards(accountCounts),从卡片手里已有的状态文档判断该画哪几条 lane,不再单独推一遍「这条 lane 有没有绑」:

状态 结果 为什么
至少一条 lane 有账号 只画这几条 用户的原话;一次登录只对应一张卡
两条都答了、都是空 两条都画 全新安装时两条 lane 的「怎么登录」引导是唯一的入口,过滤掉就是一张没门的白页。与 ChannelPoolSection 在「一条都没绑」时放弃过滤是同一条规则
还没答完 一条都不画 这里若默认画两条,国际版卡会每次打开都闪一下再收起,那正是这次要修的现象,不是它的缩小版

被过滤掉的 lane 仍然在轮询:在扫码登录页完成一次登录要能当场让对应的卡出现,不需要刷新。

REGION_CARD_ORDER 成为轮询循环、渲染循环、过滤器共用的唯一一份 lane 列表 —— 两份手写 pair 就是「轮询了却从不渲染」的来源。

连带修掉的一处

「账号使用方式」(distribution)选择器原本和 automation 开关一起钉在 region === 'cn' 上。lane 一旦会被隐藏,只绑国际版的用户就没有任何卡片承载它 —— 而 distribution 是同一个 pool 实例的属性(一个 settings key、两个网关共用),不是国内版专属设置。现在它挂在第一条可见 lane 上(国内版可见时就是国内版,国内版用户看到的没有任何变化);automation 仍然只在 cn,因为国际版网关确实没有成长体系。

验证

  • tsc -p tsconfig.json → 0
  • tsc -p tsconfig.client.json → 0
  • tsdown → 0,lib/client.js 已随源码一起提交
  • vitest run → 1400 passed / 2 failed,失败只有 tests/windows-registry-encoding.test.ts 两条硬编码写 D:\_dsh_enc_probe 的用例(本机 D: 是只读安装介质,CI 的 windows-latest 不受影响)

新增/改写的断言:

  • visibleRegionCards 五个状态各自一条用例(只绑国内 / 只绑国际 / 两条都绑 / 全空 / 尚未答完)
  • 「轮询但不渲染」的回归守卫:REGION_CARDS = REGION_CARD_ORDER,且卡里不再出现第二份 ['cn', 'global'] 字面量
  • 分账选择器在只绑国际版时仍可达
  • host-compat.test.ts 的「两条 lane 都渲染」改为「每条已绑定的 lane 都渲染」

The pool page rendered both supplier cards unconditionally, so a user who had
never signed in to the international build still got a full international card
on every visit: its endpoint, its model count at 0, and a four-step guide to
installing an app they do not have. 绑定了哪个渠道,就显示什么渠道.

`visibleRegionCards` answers which lanes to draw from the counts the card already
holds, so the pool page and the login page never derive "is this lane bound"
twice. Three states, because "no answer yet" is not "no accounts":

- some lane bound -> exactly those lanes
- all answered, empty -> both, because a fresh install has no other door in
- still reading -> none, so a lane cannot flash in and collapse back out

A filtered-out lane is still POLLED: a sign-in performed while the page is open
has to make its lane appear without a reload. `REGION_CARD_ORDER` becomes the one
list the poll loop, the render loop and the filter share.

The account-usage picker moves with it. It was pinned to the domestic card
alongside the automation switch, so an international-only user would have lost a
control that still applies: the distribution is one setting for the ONE pool
instance both gateways draw from. It now hangs off the first VISIBLE lane, which
is `cn` for every domestic user, while automation stays CN-only because that
gateway genuinely has no growth system.

Verified: tsc (host) 0, tsc (client) 0, tsdown 0, vitest 1400 passed with the two
D:-only windows-registry cases failing as documented.
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