You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The VertexAI Provider object stored in Redux has a fundamental type mismatch with the VertexProvider type definition! This leads to code relying on false type assertions and complex runtime mappings.
Problem Symptoms
Type System Lies - The isVertexProvider() function only checks the type field but claims to return a VertexProvider type containing googleCredentials and project fields
Scattered Data Storage - VertexAI configuration is stored in two places:
Provider object in llm.providers[] (basic configuration)
llm.settings.vertexai (sensitive configuration)
Inconsistent Field Naming - Redux state uses serviceAccount/projectId, but type definitions expect googleCredentials/project
Manual Mapping Required - All code using VertexAI must call createVertexProvider() for mapping, which is error-prone
Proof
The following code locations all require defensive checks or explicit mapping, indicating the type system is untrustworthy:
src/renderer/src/utils/provider.ts:159-161 - isVertexProvider() false type assertion
src/renderer/src/hooks/useVertexAI.ts:46-59 - Must call createVertexProvider() for mapping
src/renderer/src/aiCore/legacy/clients/gemini/VertexAPIClient.ts:26-30 - Needs to check if it's really a VertexProvider, otherwise manually map
src/renderer/src/aiCore/provider/providerConfig.ts:321-335 - Must call createVertexProvider() to get configuration
Redux Actual Storage
// Provider object in llm.providers[]:{
id: 'vertexai'
type: 'vertexai'✓
apiKey: string ✓
apiHost: string ✓// ❌ Missing googleCredentials, project, location}// Real configuration is in llm.settings.vertexai:{
serviceAccount: {// ❌ Should be called googleCredentials
privateKey: string
clientEmail: string}
projectId: string// ❌ Should be called project
location: string}
Expected Behavior
VertexAI configuration should have a single source of truth, and the type system should accurately reflect the actual data structure!
Steps To Reproduce
View the VertexProvider type definition in src/renderer/src/types/provider.ts
View the storage structure in Redux state src/renderer/src/store/llm.ts
Check the implementation of the isVertexProvider() function
Trace all code paths using VertexAI configuration
Expected Behavior
The type system should accurately reflect the runtime data structure
VertexAI configuration should be stored in a single, consistent location
No complex mapping functions and defensive checks are needed
Additional Context
This is an architectural design flaw, not a user-visible bug. But it leads to:
Difficult code maintenance
Easy to introduce bugs (type mismatch)
Runtime performance overhead (mapping functions)
Poor developer experience (type system cannot help developers)
Need to refactor the VertexAI Provider data storage architecture!
Note
This issue was translated by Claude.
Bug Description
The VertexAI Provider object stored in Redux has a fundamental type mismatch with the
VertexProvidertype definition! This leads to code relying on false type assertions and complex runtime mappings.Problem Symptoms
isVertexProvider()function only checks thetypefield but claims to return aVertexProvidertype containinggoogleCredentialsandprojectfieldsllm.providers[](basic configuration)llm.settings.vertexai(sensitive configuration)serviceAccount/projectId, but type definitions expectgoogleCredentials/projectcreateVertexProvider()for mapping, which is error-proneProof
The following code locations all require defensive checks or explicit mapping, indicating the type system is untrustworthy:
src/renderer/src/utils/provider.ts:159-161-isVertexProvider()false type assertionsrc/renderer/src/hooks/useVertexAI.ts:46-59- Must callcreateVertexProvider()for mappingsrc/renderer/src/aiCore/legacy/clients/gemini/VertexAPIClient.ts:26-30- Needs to check if it's really a VertexProvider, otherwise manually mapsrc/renderer/src/aiCore/provider/providerConfig.ts:321-335- Must callcreateVertexProvider()to get configurationRedux Actual Storage
Expected Behavior
VertexAI configuration should have a single source of truth, and the type system should accurately reflect the actual data structure!
Steps To Reproduce
VertexProvidertype definition insrc/renderer/src/types/provider.tssrc/renderer/src/store/llm.tsisVertexProvider()functionExpected Behavior
Additional Context
This is an architectural design flaw, not a user-visible bug. But it leads to:
Need to refactor the VertexAI Provider data storage architecture!
Original Content
Bug Description
Redux 中存储的 VertexAI Provider 对象与
VertexProvider类型定义存在根本的类型不匹配喵!这导致代码依赖于虚假的类型断言和复杂的运行时映射喵。问题症状喵
isVertexProvider()函数只检查type字段,但声称返回包含googleCredentials、project字段的VertexProvider类型llm.providers[]中的 Provider 对象(基础配置)llm.settings.vertexai中(敏感配置)serviceAccount/projectId,但类型定义期望googleCredentials/projectcreateVertexProvider()进行映射,容易出错证明喵
以下代码位置都需要防御性检查或显式映射,说明类型系统不可信喵:
src/renderer/src/utils/provider.ts:159-161-isVertexProvider()虚假的类型断言src/renderer/src/hooks/useVertexAI.ts:46-59- 必须调用createVertexProvider()进行映射src/renderer/src/aiCore/legacy/clients/gemini/VertexAPIClient.ts:26-30- 需要检查是否真的是 VertexProvider,否则手动映射src/renderer/src/aiCore/provider/providerConfig.ts:321-335- 必须调用createVertexProvider()来获取配置Redux 实际存储喵
预期行为喵
VertexAI 配置应该有唯一的真实来源,类型系统应该能够准确反映实际的数据结构喵!
Steps To Reproduce
src/renderer/src/types/provider.ts中的VertexProvider类型定义src/renderer/src/store/llm.ts中的存储结构isVertexProvider()函数的实现Expected Behavior
Additional Context
这是一个架构设计缺陷,不是用户可见的 bug。但会导致:
需要重构 VertexAI Provider 的数据存储架构喵!