Skip to content

feat: full-width chat, admin-defined multi-model discussions, and DeepSeek Search MCP - #912

Open
ljq29 wants to merge 57 commits into
DEEIX-AI:devfrom
ljq29:dev
Open

ljq29 wants to merge 57 commits into
DEEIX-AI:devfrom
ljq29:dev

Conversation

@ljq29

@ljq29 ljq29 commented Nov 17, 2026

Copy link
Copy Markdown

Summary

This PR adds three related capabilities on top of dev:

  1. Chat layout: full width and left alignment

    • New full width option (100% of the available area) alongside compact/standard/wide.
    • New independent center / left alignment setting, applied to the message list, empty
      state, skeleton and composer.
    • Persisted through chat.content_width / chat.content_align; code blocks, tables,
      Mermaid and PDF/image previews keep their own local scroll areas.
  2. Admin-defined multi-model discussion templates

    • New chat_discussion_templates table and /api/v1/admin/discussion-templates CRUD API.
    • Templates define placeholders, serial rounds with parallel steps, per-step prompts and a
      summary node. Participants can be fixed models or placeholders bound at chat time.
    • The web model picker exposes active templates as discussion:<publicID> models. Selecting
      one shows a binding bar for every placeholder; the message records the full transcript in
      chat_messages.discussion_json and a collapsible discussion panel renders it.
    • The backend runs rounds serially and steps inside a round in parallel, excludes failed turns
      from the transcript, then asks the summary model for the final answer. Events are streamed
      over NDJSON.
  3. Bundled DeepSeek Search MCP service

    • deploy/services/deepseek-search/ contains a dependency-free MCP Streamable HTTP server
      wrapping POST /v1/tools/search and POST /v1/tools/fetch.
    • The compose files include an opt-in deepseek-search profile.
    • Deployment notes explain how to add the MCP server and set the per-call price
      (750000 nanousd, matching DeepSeek's $0.75 / 1,000 successful requests).

Commits

  • feat(chat): add full-width and left-aligned chat layout
  • feat(discussion): add admin-defined multi-model discussion templates
  • feat(tools): bundle DeepSeek Search MCP service
  • feat(chat): add in-chat width and alignment control
  • fix(discussion): remember bindings and continue in background

Test plan

  • go build ./...
  • go test ./internal/domain/discussion/ ./internal/application/conversation/ -run 'TestDiscussion|TestParseConfig|TestResolveRuntime|TestValidateConfig'
  • pnpm --filter @deeix/web typecheck
  • pnpm --filter @deeix/web lint
  • pnpm --filter @deeix/web build
  • MCP smoke test: initialize and tools/list against the bundled server.
  • Deployed the built image to a Docker Compose stack: new container is healthy, /healthz
    and /readyz return 200, and chat_discussion_templates / chat_messages.discussion_json
    exist after migration.

Known limitations

  • Discussion calls currently record usage but are not settled through the existing billing
    session (Billable=false). A follow-up should aggregate the per-turn usage into the message
    billing/usage ledger.
  • Discussion runs do not yet participate in the existing cancel/resume endpoints.
  • The runtime UI binds existing placeholders; adding/removing steps at chat time is not exposed
    yet (the admin editor can add/remove rounds and steps).
  • Per-turn live deltas are emitted by the backend but the web panel currently renders the
    completed state; wiring pending-exchange updates is a follow-up.

Templates define placeholders, serial rounds with parallel steps, per-step prompts and a summary node. The web model picker exposes them as discussion:<id> models; the backend orchestrates the calls and stores the transcript on the assistant message.
Adds a dependency-free MCP Streamable HTTP server wrapping DeepSeek's Search and Fetch APIs, plus an opt-in compose profile and deployment notes.
Restores placeholder model bindings from the latest discussion message and a per-conversation local draft. Discussion runs now acquire the generation lifecycle, register their run and publish events, so leaving the page no longer aborts the round loop and the existing run resume stream can replay the final result.
ljq29 added 15 commits November 17, 2026 20:49
Adds the discussion send request and message discussion field to the generated Swagger and TypeScript contracts.
Moves the width/alignment trigger out of the conversation-only header into a labelled control above the composer, so it is visible on the new-chat landing page as well.
Keeps request calls out of components as required by the web architecture check and removes the unguarded status type assertion.
Domain structs stay protocol-free; transport and persistence payloads now carry the JSON field names.
@ljq29

ljq29 commented Nov 17, 2026

Copy link
Copy Markdown
Author

Updated with three follow-up commits:

  • Streamed discussion rounds. Each round is now rendered as its own assistant utterance with a model switch, fed by the discussion_turn_delta / discussion_turn_done / discussion_round_done events the backend already emitted but the client dropped. The summary streams through discussion_summary_delta and the final delta now carries replace: true, so an N-round template speaks N+1 times without waiting for user input. Usage cells open the round and model they belong to.
  • Docked workflow rail + select-all models. The admin workflow preview is a full-height rail flush with the right edge instead of a floating card, and each round's model list gained a 全部 switch that greys out the individual chips and restores the previous selection when turned off.
  • Composer binding layout. The summary model keeps a row of its own; discussion models fill the row and wrap only when they run out of room.

pnpm check (lint, typecheck, arch) and pnpm build pass; API/Web/Desktop/Docker CI jobs are green.

The backend already emitted discussion_start, discussion_turn_delta,
discussion_turn_done, discussion_round_done, discussion_summary_delta and
discussion_done, but the web client treated unknown event types as
"unrecognized" and dropped them, so a discussion only appeared after the whole
run had finished.

Stream contract
- shared/api/conversation.ts: the six discussion types join
  STREAM_MESSAGE_EVENT_TYPES and route to one onDiscussionEvent callback. The
  error fallthrough now narrows to the error variant instead of reading error
  fields off the whole union.
- shared/api/conversation-types.ts: typed variants plus DiscussionStreamEvent.
- features/chat/model/discussion-stream.ts (new): applyDiscussionEvent folds an
  event into the live state. Turns are keyed by (round, stepId): a delta
  creates or appends, turn_done replaces, round_done replaces that round's
  turns, done swaps in the server state. A replayed discussion_start keeps the
  turns collected so far.

Live state
- PendingExchange gains assistantDiscussion; use-chat-run-stream feeds it from
  onDiscussionEvent and streams summary deltas into assistantText.
- use-chat-branch-state maps it onto ChatAreaMessage.discussion and keeps it
  while merging pending state; settleCompletedExchange adopts the persisted
  discussion.
- use-chat-data applies the same events on the resume stream, so switching away
  and back keeps the round progress.

Rendering
- message-discussion.tsx: one utterance per round, with a chip per model
  ordered 模型 1 … 模型 n by placeholder order; the selected model's Markdown
  streams through StreamdownRender. Usage cells select the round and model and
  scroll to it; the detail row keeps a single 全部 chip that resets the
  selection.
- message-bot.tsx: a running discussion no longer renders the empty-body
  skeleton.

Backend
- discussion_start now carries the template placeholders, so the client can
  label 模型 N without the template.
- the final delta is emitted with replace: true, because the summary already
  streamed as discussion_summary_delta.

An N-round template now speaks N+1 times without waiting for user input.
…-all switch

Workflow preview
- The preview was a 320px floating card over the editor. It is now a
  full-height rail flush with the right edge (23rem at xl, 27rem at 2xl, 24px
  padding) with a border-left instead of a floating card, so a wide screen
  gives the workflow real room without squeezing the form. Narrow screens still
  open it below the editor.

Select-all models
- Each round's 参与模型 list starts with a 全部 switch. Turning it on joins
  every discussion placeholder, greys the individual chips, and remembers the
  selection it replaced; turning it off restores that selection, or keeps one
  model when there was nothing to restore.
- Adding a discussion model still appends it to every round, so 全部 stays
  satisfied.
- Reordering rounds clears the remembered selections, which are keyed by
  position.

i18n: admin-discussions gains allModels (zh-CN / en-US).
The summary model is the last node of the workflow, so it no longer shares a
grid cell with the discussion models: it gets a full-width row above them,
keeping its 总结 badge and primary tint.

Discussion models fill the row with flex-wrap and a 13rem minimum, so they sit
side by side until they run out of room instead of being pinned to two
columns. Selects keep an aria-label because their container is no longer a
<label>.
docs/DISCUSSIONS.md describes the feature end to end: the template shape
(placeholders, serial rounds with parallel steps, the summary node), the
transcript the backend builds, the NDJSON events and how the client folds
them into the transcript, the panel and admin editor rules, and the known
limits. Its last section records what this round changed: streamed round
utterances, the docked workflow rail, the select-all model switch and the
summary row in the composer, with the files each change touched.

README and README.zh-CN link the new document next to the architecture guide.
@ljq29

ljq29 commented Nov 17, 2026

Copy link
Copy Markdown
Author

Added docs/DISCUSSIONS.md (linked from both READMEs) covering the template shape, the transcript the backend builds, the NDJSON discussion events and how the client folds them into the transcript, the panel and admin editor rules, known limits, and a final section with the files this round touched.

The three feature commits were reworded to carry their design notes in the message body; the trees are unchanged (git diff between the old and new tips is empty), so this is a message-only rewrite plus the docs commit.

…vent payloads

Prompt capture (debug)
- domain Turn gains Prompt, State gains SummaryPrompt.
- generateDiscussion now returns the messages it actually sent (after
  buildTextTaskGenerateInput normalises system messages for the adapter), and
  both the round turns and the summary turn keep it.

Follow-up context
- discussionPriorContext walks ListMessageAncestors from the new user message
  and takes the nearest non-empty assistant message (truncated to 8000 runes).
- discussionTurnUserContent / discussionSummaryUserContent assemble
  "上次讨论的结果 + 用户本次问题 + 上一轮及更早的讨论记录", so a follow-up in
  the same conversation continues from the previous discussion's conclusion
  instead of starting from the bare question.

Event payload shape
- discussion_start, discussion_turn_done, discussion_round_done and
  discussion_done used to marshal the Go domain structs directly, which emits
  Round / StepID style keys the web client cannot read; the live panel only
  looked right after the final persisted state arrived. They now go through
  the discussion*Payload helpers, so every event matches discussion_json.
- service_discussion_payload.go is reorganised around those helpers and adds
  turn.prompt / state.summaryPrompt.
…is set up

The binding effect returned early whenever the conversation/template scope was
unchanged, so the seed was only read on the first run of that scope. Messages
load after that first run, which meant the composer fell back to the template
defaults and showed models the last discussion never used.

The same-scope branch now reapplies the last discussion's bindings when they
arrive or change, until the user picks a model themselves; the seeded values
are written back to localStorage so a reload keeps them.
…layable

The generation stream retains a bounded event window, so a resumed run can
lose discussion_start. applyDiscussionEvent dropped every turn event while
there was no state, which left the panel empty until discussion_done arrived
and the whole discussion appeared at once.

Turn events now create a minimal running state on their own, and the panel
derives its rounds from the turns when no plan is available, so progress keeps
streaming on a resumed run.
§7 documents the binding precedence (last run > stored > template default)
and that the seed is applied whenever it arrives; §8 no longer lists the lost
discussion_start as a limitation; §11 is the v0.4.6-fork.14 change log with
the cause of each symptom.
@ljq29

ljq29 commented Nov 18, 2026

Copy link
Copy Markdown
Author

Two fixes for issues reported on the deployed build:

  • Composer models vs. the models a discussion actually used. The binding effect bailed out whenever the conversation/template scope was unchanged, and the seed (the last discussion's bindings) arrives with the message list — after that first run. The composer therefore fell back to the template defaults. The same-scope branch now reapplies the seed whenever it arrives or changes, writes it back to localStorage, and stops doing so once the user picks a model.
  • Rounds stuck on 未开始 until the run finishes. The generation stream retains a bounded window, and a discussion's deltas evict discussion_start from it, so a resumed stream had no plan and applyDiscussionEvent dropped every turn event. Turn events now create a minimal running state on their own, and the panel derives its rounds from the turns when no plan is available, so progress streams on a resumed run too.

The reducer was replayed in Node for both an ordered run and a deltas-only resumed run; pnpm lint / typecheck / check:arch / build pass. docs/DISCUSSIONS.md §7/§8 and a new §11 cover both fixes.

A follow-up used to send only the previous assistant answer plus the new
question, which dropped the previous user message and looked nothing like a
normal chat turn. Discussion rounds and the summary now share the branch's
history as real user/assistant messages:

- discussionHistoryMessages walks ListMessageAncestors from the new user
  message, keeps user/assistant roles, and drops empty or non-history entries.
  Earlier discussions appear as their final answer only; per-model utterances
  stay in discussion_json.
- Each turn is system prompt + history + the current question (with the in-run
  transcript from round 2 on), so the previous question's constraints survive.
- generateDiscussion runs fitGenerateInputToModelBudget with the route's
  upstream model and capabilities, so history is trimmed per model exactly like
  a normal chat turn; the ancestor depth follows ContextMaxTurns.

The debug view now shows that history too, since it renders the messages
actually sent.
§3 now documents the history chain, the per-model token budget, and that only
each discussion's final answer enters history; §8 updates the limits; §12 logs
the v0.4.6-fork.15 change.
@ljq29

ljq29 commented Nov 18, 2026

Copy link
Copy Markdown
Author

Discussion turns now carry the branch's real conversation history instead of a flattened "previous answer" block:

  • discussionHistoryMessages walks ListMessageAncestors from the new user message and keeps user/assistant roles, so the previous question (and its constraints) survives. Earlier discussions appear as their final answer only; per-model utterances stay in discussion_json.
  • Each turn is system prompt + history + current question, with the in-run transcript appended from round 2 — the same shape as a normal chat turn.
  • generateDiscussion runs fitGenerateInputToModelBudget with the route's upstream model and capabilities, so history is trimmed per model (oldest turns first, system prompt and current question kept). Ancestor depth follows ContextMaxTurns.

The debug mode shows that history too, since it renders the messages actually sent. docs/DISCUSSIONS.md §3/§8 and a new §12 cover the change; the turn-content test was updated to pin the new structure. API CI (including the new test) is green.

ljq29 and others added 23 commits November 18, 2026 11:26
修复多轮讨论实时状态与轮次自动收起
多轮讨论生成期间提前展示实际 Prompt
多轮讨论 Prompt 支持按消息两层折叠
多轮讨论支持每轮并行或串行执行
手动功能 CI 不再强制执行依赖审计
- keep parallelPrompt and serialPrompt per round
- restore the target mode's prompt when switching, filling its default if untouched
- add a reset-to-default action to the round prompt editor
- add serial default prompts for the first and later rounds in the editor and backend
多轮讨论按执行方式隔离 Prompt
feat: pin discussion configuration per conversation
fix: unwrap discussion snapshot responses once
fix: include config in discussion snapshot templates
feat: sync discussion defaults with manual overrides
fix: standardize discussion model card sizing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant