Files
makelore/.project-docs/30-worklog/tasks/20260806-design-multisession-ui-4e7d.md
brother7 03dae62cf3 feat: 支持 AI 设计项目多会话交互
需求:用户可在同一设计项目中新建和切换会话,任务列表保持项目级共享。

实现:
- 增加会话选择、新建入口及本地数据迁移
- Conversation 独立消息、Brief、Quote 与流式状态
- 保留项目任务并修复 Task revision 与 ABA 异步竞态
- 保持 Enter 发送、Shift+Enter 换行及 IME 保护
2026-08-06 18:22:15 +08:00

4.0 KiB

Task: AI 设计项目多会话客户端

Identity

  • Task ID: 20260806-design-multisession-ui-4e7d
  • Mode: Feature
  • Branch: codex/20260806-design-multisession-ui-4e7d-design-multisession-ui
  • Worktree: D:\Datas\OthersProjects\makelore-design-multisession-4e7d
  • Base commit: 4980894017
  • Owner: codex
  • Status: Completed

Scope

  • Extend the shared AI Design contract with project Conversations and Conversation-tagged events/tasks.
  • Add Electron adapter and host API support for listing, creating, reading and submitting to a Conversation.
  • Add renderer store state/actions for the active Conversation and protect asynchronous/streaming updates with Workspace + Conversation identity.
  • Add a compact Conversation selector and “new conversation” action to AI Design while leaving the generation-task panel project-scoped.
  • Migrate the local fallback Workspace data model to create a default Conversation.
  • Cover adapter, route, store and page behavior, including Conversation switching and project-level task persistence.

Intent And Constraints

  • Product model: one design project contains multiple independent conversations; starting a new conversation must not create a new project.
  • The selected Conversation owns messages, Brief, Quote and turnRevision; changing Conversations must not leak pending or streaming text.
  • Generation tasks and assets belong to the project and remain visible when the selected Conversation changes.
  • Each Conversation uses its stable Gateway Session/stream. Switching Conversation reconnects to that Session without changing projects; task events delivered on any Conversation stream are still reduced by workspaceId only.
  • Preserve compatibility with the deployed single-conversation server during rollout where practical, without retaining two sources of client state.
  • Keep the existing visual language and input behavior, including Enter to send, Shift+Enter for newline and IME composition protection.

Outcome

  • Split the client model into Workspace, Conversation and Workspace-owned generation tasks, including local v2-to-v3 migration of the previous single chat into a default historical Conversation.
  • Added Electron/host APIs for Conversation list/create/read/turn/confirm/event flows and reused the server-owned persistent Gateway Session for each Conversation.
  • Added active Conversation state, guarded async/stream updates by Workspace + Conversation identity, and preserved the Workspace task list while switching chats.
  • Added generation-token and monotonic-revision guards for Conversation/Workspace ABA races, including late failures.
  • Task event watermarks now advance only from real stream events; REST freshness continues to use per-task updatedAt.
  • Added Conversation switching and new-Conversation actions to both the AI Design header and expanded project sidebar, with a global in-flight guard against duplicate creation.
  • Preserved composer keyboard behavior: Enter sends, Shift+Enter inserts a newline, and IME composition Enter is ignored.

Verification

  • TypeScript tsc --noEmit: passed.
  • Focused AI Design suites: 7 files / 93 tests passed, including all 19 migrated adapter behavior tests.
  • ESLint for all changed TypeScript/TSX files: passed.
  • Production Vite + Electron build: passed; only existing chunk-size/dynamic-import warnings remain.
  • Full Vitest run is not green on the base environment: 19 failures reproduce in the original client tree (missing zip/.opencode resources and existing timing checks); one additional speech-transcription test is outside this task's diff and passes only with the user's uncommitted original-tree changes.

Follow-ups

  • Publish only after server migration 0033 and the multi-conversation API are live.
  • Consider pagination/search when a project grows beyond the six recent Conversations shown inline in the sidebar.

Promotion Candidates

  • Promote Workspace/Conversation/Task client-state ownership and stream routing into the canonical client architecture/current-state documents during integration.