When TutorBot is connected to IM channels (e.g. Feishu, WeChat),
users can send images and other multimedia messages. These messages
are stored with content as an array of content-part objects rather
than a plain string. The frontend assumes content is always a string,
causing React Error #31 (Objects are not valid as a React child)
and rendering the chat page unusable.
Changes:
- Add normalizeMessageContent() utility to safely convert array/object
content to displayable strings
- Fix BotChatPage history parsing to handle non-string content
- Fix UnifiedChatContext hydrateMessages for non-string content
- Fix last_message display with truncation and type safety in
SessionList and HistorySessionPicker
- Normalize content to string and strip reasoning_content in backend
get_bot_history and get_recent_active_bots
Stability release after v1.3.0 covering safer RAG/KB routing, stronger
embedding validation, more reliable Docker/TutorBot restarts, Web UX
fixes, and Windows/encoding hardening. See assets/releases/ver1-3-1.md
for the full notes.
Made-with: Cursor
Extract lightweight `SimpleComposerInput` to isolate keystroke renders.
Colocate input state in `agents/[botId]/chat/page.tsx` to prevent full-page lag.
Export @mention utility helpers from `ComposerInput.tsx` for cross-component use.
Address follow-up feedback from StarNight2021 regarding tutorbot-only performance.
This completes the performance overhaul by ensuring all chat entry points use optimized state colocation patterns.
Extract `ComposerInput` component to isolate frequent keystroke renders.
Refactor `ChatComposer` to use `hasContent` flag instead of full `input` state.
Apply `React.memo` to heavy config panels (Quiz, Math, Research, Visualize).
Stabilize parent callbacks in `ChatPage` using `useCallback`.
Fix residual syntax errors and missing `canSend` definition in composer.
Address HKUDS/DeepTutor#351 by implementing deep state colocation.
- Add i18n keys for the Regenerate action button (en: "Regenerate",
zh: "重新生成") and switch `ChatMessages.tsx` from the hardcoded
"Regenerate" string to `t("Regenerate")`, matching the existing
`t("Copy")` pattern in the same row.
- When a regenerate request is rejected pre-flight (server returns a
terminal `error` with `reason` = `regenerate_busy` or
`nothing_to_regenerate`), the optimistic `POP_LAST_ASSISTANT` +
`STREAM_START` placeholder is now rolled back via a new
`RESTORE_ASSISTANT` reducer action. The popped message is kept in a
per-key ref (`pendingRegenerateRef`) and cleared on `done` or any
terminal result, so the transcript stays in sync with the server and
the user doesn't silently lose their last reply.
Made-with: Cursor
Rebased onto dev (post-#348) and resolved two UI conflicts (`web/app/(workspace)/chat/[[...sessionId]]/page.tsx` drops the now-dead `replaySnapshot` helper; `web/components/chat/home/ChatMessages.tsx` switches the last-assistant action button from the old `RotateCcw`/Retry to `RefreshCcw`/Regenerate). Smoke tests green (199 passed) and all required checks pass.
Merging: adds a `regenerate` capability wired through CLI (`/regenerate` · `/retry`), WebSocket (`type: "regenerate"`), and Web UI (per-message Regenerate button). Backend rolls back the trailing assistant via `SQLiteSessionStore.delete_message`, reuses `start_turn` through `_persist_user_message=False` / `_regenerate=True`, skips `memory_service.refresh_from_turn` on regeneration, and surfaces non-fatal `regenerate_busy` / `nothing_to_regenerate` errors. Also includes empty-response diagnostics in `_stage_responding`. 18 new tests.
Resolved conflicts in:
- deeptutor/agents/notebook/summarize_agent.py
Kept the YAML-driven record_hints lookup from dev (covers chat,
co_writer, guided_learning, default), instead of the inline
dict from guide2.0 which only had chat + co_writer.
- deeptutor/capabilities/visualize.py
Kept dev's load_answer_now_prompts(...) path so the answer-now
fast path stays prompt-externalised under
deeptutor/agents/visualize/prompts/{en,zh}/answer_now.yaml.
- deeptutor/services/prompt/manager.py
Merged the MODULES list: dropped 'guide' (deleted by guide2.0),
added 'book' from guide2.0, and kept dev's 'notebook',
'visualize', 'chat' modules.
Made-with: Cursor
- Move inline LLM prompts out of capabilities/agents into versioned
prompt YAMLs under each agent's prompts/{en,zh}/:
- notebook: analysis_agent, summarize_agent
- question/research/solve/visualize: answer_now
- Slim down capability modules (_answer_now, deep_question,
deep_research, deep_solve, visualize) to load prompts via the
prompt manager instead of hard-coding strings
- Update services/prompt/manager.py to support the new prompt paths
- Refresh web config panels (quiz, research, visualize, math-animator)
and shared types to align with the new capability options
- Update Mermaid, ChatMessages, TracePanels and settings page,
plus en/zh locales for the new copy
Made-with: Cursor
- Promote "Answer now" to a universal escape hatch via answer_now_context;
orchestrator re-routes any capability to chat._stage_answer_now.
- Co-Writer: draggable split + persistent ratio + line-anchored
bidirectional scroll sync using a hidden mirror for wrap-aware editor y.
- SaveToNotebookModal: optional message-selection mode with quick presets;
rebuild transcript / userQuery from the selected subset.
- Adopt the real notebook API (/api/v1/notebook/*) across Knowledge tab,
guide notebook picker, and save-to-notebook flow; new typed helpers in
web/lib/notebook-api.ts (listNotebooks/getNotebook/createNotebook/...).
- Extract CollapsibleConfigSection; unify Quiz / Math Animator / Visualize
/ Deep Research panels behind one collapsed-summary header.
- Replace streaming spinner with a dedicated Stop button; persistent
composer header; mask-gradient on messages container.
- TutorBotManager: public load/save/merge API; atomic write via temp +
Path.replace; merge_bot_config with explicit-clear semantics; new
tests/services/tutorbot/test_manager_config.py.
- MarkdownRenderer: trackSourceLines passes data-source-line through;
RichCodeBlock skips Prism for unlabeled/plaintext fences; mermaid
detection includes flow/seq/sequence editor.md fences.
- UI/theme: deeper foregrounds + warmer borders for light/Snow themes;
/guide migrated off hardcoded slate/indigo to design tokens;
HistorySessionPicker themed and timestamp-seconds bug fixed.
- Filter system messages out of UnifiedChatContext.hydrateMessages and
ChatMessageList so backend grounding context never renders as a bubble.
- Bug fixes (already merged earlier in dev):
* tutorbot config wipe on restart (#332)
* selective_access_log middleware unpack crash (#334/#335)
* 15 npm security vulnerabilities — jspdf/next/mermaid (#330)
- Drive-by: remove "// README" typo from .env.example_CN.
- Add v1.1.1 release notes and update README.
Made-with: Cursor
- Memoize ChatMessageList, UserMessage, and ReferenceChips components.
- Stabilize onRetryMessage callback using useCallback in HomePage.
- Prevent unnecessary re-renders of the entire message history during text input.
- Replace litellm with native openai + anthropic SDKs across both
services and tutorbot layers
- Add 5 new providers: mistral, stepfun, xiaomi_mimo, qianfan, ovms
- Add `backend` field to ProviderSpec for SDK routing
- New TutorBot OpenAICompatProvider (openai SDK) and AnthropicProvider
(anthropic SDK), replacing LiteLLMProvider
- Rewrite services/llm/executors.py to use openai SDK directly
- Remove litellm from factory.py routing, token_tracker, provider_cmd
- Auto-fallback to streaming for tool-call format errors (fixes#265)
- Settings UI: provider dropdown with auto base-url fill
- Clean up litellm from requirements/cli.txt and pyproject.toml
Made-with: Cursor
This PR fixes multiple Windows compatibility issues that prevented
the Math Animator from generating videos on Windows systems.
### Changes
1. **renderer.py**: Fix subprocess execution on Windows
- Replace `asyncio.create_subprocess_exec` with `subprocess.run` + `asyncio.to_thread`
- The original approach silently fails on Windows when uvicorn uses SelectorEventLoop (default)
- New approach works regardless of event loop type
2. **code_generator_agent.yaml (en/zh)**: Add Manim v0.20.1 compatibility constraints
- Prohibit `MarkupText` (requires LaTeX)
- Prohibit `stroke_dash_pattern` parameter (not supported in v0.20.1)
- Prohibit `save_state()` method (not supported in MovingCameraScene)
- Applied to both `generate_system` and `retry_system` sections
3. **ChatComposer.tsx**: Suppress hydration warning for i18n placeholder
- Add `suppressHydrationWarning` to textarea
- Resolves SSR/CSR text mismatch warning for language-specific placeholders
### Testing
- ✅ CLI mode: Successfully generated Pythagorean theorem animation (660KB)
- ✅ Web mode: Successfully generated cone cross-section animation
- ✅ Auto-retry: First attempt error → LLM repair → second attempt success
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>