CHAT-401 P0 | 定义 ChatEntryContext 模型 + Route 参数 #39

Closed
opened 2026-06-06 16:24:12 +08:00 by wangdl · 1 comment
Owner

目标

iOS 侧定义统一的 AI 入口上下文模型,所有入口都必须传 ChatEntryContext。

内容

  • 定义 ChatEntryContext struct (scopeType, scopeId, parentKnowledgeBaseId, parentMaterialId, createdFrom)
  • Route.aiChat 改为接受 ChatEntryContext 参数
  • AIChatPage init 接收 ChatEntryContext
  • 删除旧的无 scope 兜底逻辑
## 目标 iOS 侧定义统一的 AI 入口上下文模型,所有入口都必须传 ChatEntryContext。 ## 内容 - 定义 ChatEntryContext struct (scopeType, scopeId, parentKnowledgeBaseId, parentMaterialId, createdFrom) - Route.aiChat 改为接受 ChatEntryContext 参数 - AIChatPage init 接收 ChatEntryContext - 删除旧的无 scope 兜底逻辑
wangdl added this to the M-CHAT:AI 会话 Scope 系统重构(iOS 侧) milestone 2026-06-06 16:24:12 +08:00
Author
Owner

完成

新增模型 (APIModels.swift)

  • ChatScopeType enum (knowledgeBase/folder/material/knowledgeItem/global)
  • ChatEntryContext struct (scopeType/scopeId/scopeName/parentKnowledgeBaseId/createdFrom)
  • ChatScopeSnapshot struct
  • 更新 ChatSession (新增 13 个 scope 字段)
  • 更新 ChatMessage (新增 scopeSnapshot)
  • 更新 ChatCitation (新增 sourceId/lineStart/lineEnd)
  • CreateSessionRequest (scopeType/scopeId/parentKnowledgeBaseId/createdFrom)
  • UpdateChatSessionRequest (title/isPinned/isArchived/modelMode/modelId)

Route 更新 (Route.swift)

  • aiChat 从 knowledgeBaseId: String? 改为 context: ChatEntryContext?

Service 更新 (APIService.swift)

  • createSession 接受 ChatEntryContext
  • listSessions 支持 scopeType/scopeId/parentKnowledgeBaseId 过滤
  • 新增 updateSession (PATCH)

ViewModel 更新 (AIChatViewModel.swift)

  • setKnowledgeBase → setEntryContext
  • createNewSession 使用 entryContext
  • load 按 scope 查找已有会话

5 个调用点已更新

  • LibrarySubpages:396 → knowledge_base scope
  • 其余 4 处 → nil (global,后续 #40-#44 细化)
## 完成 ### 新增模型 (APIModels.swift) - ChatScopeType enum (knowledgeBase/folder/material/knowledgeItem/global) - ChatEntryContext struct (scopeType/scopeId/scopeName/parentKnowledgeBaseId/createdFrom) - ChatScopeSnapshot struct - 更新 ChatSession (新增 13 个 scope 字段) - 更新 ChatMessage (新增 scopeSnapshot) - 更新 ChatCitation (新增 sourceId/lineStart/lineEnd) - CreateSessionRequest (scopeType/scopeId/parentKnowledgeBaseId/createdFrom) - UpdateChatSessionRequest (title/isPinned/isArchived/modelMode/modelId) ### Route 更新 (Route.swift) - aiChat 从 knowledgeBaseId: String? 改为 context: ChatEntryContext? ### Service 更新 (APIService.swift) - createSession 接受 ChatEntryContext - listSessions 支持 scopeType/scopeId/parentKnowledgeBaseId 过滤 - 新增 updateSession (PATCH) ### ViewModel 更新 (AIChatViewModel.swift) - setKnowledgeBase → setEntryContext - createNewSession 使用 entryContext - load 按 scope 查找已有会话 ### 5 个调用点已更新 - LibrarySubpages:396 → knowledge_base scope - 其余 4 处 → nil (global,后续 #40-#44 细化)
Sign in to join this conversation.
No description provided.