CHAT-501 P0 | AIChatView 接入 open-or-create 接口 #45

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

目标

AIChatView 不再猜 scope。初始化时通过 ChatEntryContext 调用 open-or-create API。

逻辑

  1. 接收 ChatEntryContext
  2. POST /chat/sessions/open-or-create
  3. 拿到 sessionId + isNew + session
  4. 加载历史消息
  5. 非新会话时恢复历史,新会话时显示 greeting
## 目标 AIChatView 不再猜 scope。初始化时通过 ChatEntryContext 调用 open-or-create API。 ## 逻辑 1. 接收 ChatEntryContext 2. POST /chat/sessions/open-or-create 3. 拿到 sessionId + isNew + session 4. 加载历史消息 5. 非新会话时恢复历史,新会话时显示 greeting
wangdl added this to the M-CHAT:AI 会话 Scope 系统重构(iOS 侧) milestone 2026-06-06 16:24:13 +08:00
Author
Owner

完成

AIChatViewModel.load() 简化:

func load() async {
    let ctx = entryContext ?? ChatEntryContext(scopeType: .global, ...)
    let session = try await RagChatService.shared.createSession(ctx: ctx)
    await loadSession(session.id)
}

直接调用 POST /rag-chat/sessions (open-or-create)。后端根据 scope 自动返回已有会话或创建新会话。移除了冗余的 listSessions + scope matching 逻辑。

## 完成 AIChatViewModel.load() 简化: ```swift func load() async { let ctx = entryContext ?? ChatEntryContext(scopeType: .global, ...) let session = try await RagChatService.shared.createSession(ctx: ctx) await loadSession(session.id) } ``` 直接调用 POST /rag-chat/sessions (open-or-create)。后端根据 scope 自动返回已有会话或创建新会话。移除了冗余的 listSessions + scope matching 逻辑。
Sign in to join this conversation.
No description provided.