Conversation
collectDiagnostics 用 providerSummaries.some(id === 'longbridge-broker') 判断 券商是否连接,但 providerSummaries 只是「已注册 provider」列表,而 broker 在构造 函数里被无条件注册 —— 该表达式恒为 true,账户数还是写死的字面量 1,从未查询过 真实账户。改为按 kind === 'broker-account' 找到 broker 并调用 accounts(),与 entryFor(Connections 界面)同源:未登录时 accounts() 返回 ok:false,据实上报 未连接、0 个账户。 修复前 12 pass / 1 fail → 修复后 13 pass / 0 fail。 Closes helsome#245
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.
Closes #245
问题
诊断包里 broker 的两个字段是常量,与真实登录状态无关:
providerSummaries来自listFinancialProviders()→providerRouter.list(),即所有已注册的 provider;broker 在构造函数里无条件注册(kernelHost.ts:341),所以some(...)恒为true,账户数还是字面量1。未登录任何券商时,导出的诊断包依然写{ connected: true, accountCount: 1 }。改动
apps/electron/src/main/kernelHost.tsbrokerAccountFacts():按kind === 'broker-account'取到 broker provider(不再重复硬编码'longbridge-broker'字面量),调用accounts()得到真实账户数;ok && data.length > 0才算已连接,探测抛错按未连接处理(诊断包不能因为探测失败而失败)。collectDiagnostics用它的返回值替换原来的两个常量表达式。这条路径与 Connections 界面的
entryFor(kernelHost.ts:1741-1753)同源 —— 那里也调用provider.accounts();LongbridgeBrokerAccountProvider.accounts()未登录时返回{ ok: false, error: { code: 'AUTH_EXPIRED' } }(providers/longbridge/broker.ts:72-92),登录后返回 1 条。apps/electron/src/main/kernelHost.test.tsProviderRouter.list从常量[]改为可控的routerProviderList(beforeEach重置),使「provider 已注册但未登录」这一状态可在单测里构造。app.getVersion/app.isPackaged(原来只有getPath),否则collectDiagnostics在本进程内不可调用。{ connected: false, accountCount: 0 };有 1 个账户 →{ connected: true, accountCount: 1 }。验证
12 pass / 1 fail{ "accountCount": 1, "connected": true },期望{ "accountCount": 0, "connected": false }13 pass / 0 failbun run typecheck:@finagent/core、@finagent/i18n、@finagent/shared、@finagent/ui、@finagent/electron全部Exited with code 0重叠披露
apps/electron/src/main/kernelHost.ts同时被 5 个 open PR 触及(#97、#64、#56、#53、#4)。已逐个拉取各 PR 的 patch 与改动块标题比对:没有一处改动collectDiagnostics的 broker 字段或新增brokerAccountFacts;最接近的是 #4 的@@ -2101,6 +2135,9 @@(另一个方法的env构造块),与本次改动不相交。kernelHost.test.ts侧本 PR 只改 mock 的两个字段与beforeEach,其余 PR 在该文件上的改动块分别是@@ -1,11、@@ -224、@@ -254、@@ -337、@@ -457附近,也未重叠。若上述任一 PR 先合入,本分支按需 rebase。