Commit Graph

2047 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
1596807242 refactor chat capability & RAG pipeline(llamaindex) 2026-05-13 21:36:07 +08:00
whf
a8e154fc18 Block 5+6: 12 integration tests for LLM+RAG, 64/64 full regression, moved complete import to module level 2026-05-13 21:24:37 +08:00
whf
f761c34d29 Block 4: RAG retrieval via RAGService injected into system prompt before LLM call 2026-05-13 21:06:31 +08:00
whf
e65893feca Block 3: Structured prompt templates in deeptutor/learning/prompts.py, 11 stages with format() placeholders 2026-05-13 20:59:13 +08:00
whf
99fec2e51e Block 2: Replace _mock_llm() with real await complete() via DeepTutor LLM factory 2026-05-13 20:47:30 +08:00
whf
99798ade00 Block 1: LLM Factory API probe - module-level async complete()/stream() 2026-05-13 20:31:26 +08:00
unknown
ed9654a8b5 fix: address 7 confirmed security/code-quality audit findings (C2,C3,H1-H5) 2026-05-13 00:40:49 +08:00
whf
7193006cbd fix: 5 minor code quality improvements in guided_learning router
- Fix 1: Chinese comment → English
- Fix 2: Move late imports (PydanticValidationError, KnowledgePoint, LearningModule, HTTPException) to top-level
- Fix 3: Remove duplicate HTTPException imports in except blocks
- Fix 4: Document init_modules reset behavior for incremental module addition
- Fix 5: Add book_id validation to all 4 endpoints (+ colon per Codex review)

Codex-reviewed, 52/52 tests pass.
2026-05-12 23:35:53 +08:00
whf
7225eeb378 fix: restore guided_learning frontend UI integration lost in upstream merge 2026-05-12 22:27:04 +08:00
Bingxi Zhao
c7688fd268 Merge pull request #443 from wedone/feat/delete-chat-turn
feat: add delete chat turn functionality with attachment cleanup
2026-05-12 19:14:11 +08:00
Bingxi Zhao (Frank)
b5fcbfe6a8 fix(session-api): use apiFetch in deleteMessage for multi-user auth
deleteMessage was the one remaining raw fetch() call in session-api.ts.
After PR #474 wired multi-user auth through apiFetch (which attaches the
JWT bearer token from local storage / cookies), this call would fail with
401 Unauthorized in multi-user mode.

Switch to apiFetch to match the convention established for every other
authenticated session call in this file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:54:35 +08:00
unknown
3dd5771066 Sync upstream: merge HKUDS/DeepTutor main (up to v1.3.10)
# Conflicts:
#	deeptutor/api/main.py
#	web/app/(workspace)/chat/[[...sessionId]]/page.tsx
#	web/components/chat/home/ChatMessages.tsx
2026-05-12 18:39:54 +08:00
unknown
8520a72a18 Merge branch 'guided-learning-fix': 14 bug fixes for guided-learning module 2026-05-12 18:26:16 +08:00
unknown
fb2f8d7d77 fix(L1): improve init_modules merge — update existing modules instead of skipping (codex P2) 2026-05-12 18:12:21 +08:00
unknown
f213b1c228 fix(L1): incremental merge in init_modules to preserve existing modules and progress 2026-05-12 17:59:31 +08:00
unknown
ccfc64a381 fix(M9): add validation error handling with clear messages in init-modules 2026-05-12 17:47:38 +08:00
unknown
95ce77c721 fix(M4): auto-create initial repetition state when missing in submit_answer 2026-05-12 17:39:59 +08:00
unknown
0b71253cf5 fix(H3): clarify _current_knowledge_points logic — explicit match then fallback 2026-05-12 17:32:44 +08:00
unknown
acadcf6c47 fix(H8): remove unused 'key' variable in record_quiz_attempt 2026-05-12 17:30:43 +08:00
unknown
d16e749c34 fix(H9): remove knowledge_points from dict before unpacking to avoid duplicate argument 2026-05-12 17:27:18 +08:00
unknown
19bc959b9a fix(H1): persist new LearningProgress immediately in get_or_create to prevent race condition 2026-05-12 17:25:30 +08:00
WeDone
ee9483b0d5 style: fix pre-commit issues (ruff-format, prettier, bandit nosec) 2026-05-12 16:51:22 +08:00
WeDone
1c8860291d fix: check was_running before deleted to return 409 instead of 404 2026-05-12 16:51:22 +08:00
WeDone
e35fbd41b7 fix: resolve code review blockers - was_running check before deletion and temp ID resolution 2026-05-12 16:51:22 +08:00
WeDone
45ef593684 feat: add deleteMessage API and DELETE_TURN reducer action 2026-05-12 16:51:22 +08:00
WeDone
a68591b7e3 feat: 扩展 MessageItem 数据结构,增加 id 字段支持删除会话问答 2026-05-12 16:50:46 +08:00
Bingxi Zhao
6168a8bc29 Merge pull request #474 from wedone/fix/mu-data
fix: 系统性修复多用户数据隔离问题
2026-05-12 16:47:18 +08:00
Bingxi Zhao (Frank)
8bae3caedb fix(multi-user): resolve rebase regressions and decouple auth from middleware
After rebasing onto current dev (v1.3.10), several issues surfaced that the
original PR did not account for:

Frontend (rebase regressions from older PR base):
- web/lib/knowledge-api.ts: restore 6 KnowledgeBaseSummary fields
  (id, source, assigned, read_only, provenance_label, available) that the
  multi-user knowledge feature added between the PR base and current dev.
- web/app/(workspace)/agents/page.tsx: restore the array-vs-{bots}
  response shape fallback; the tutorbot list endpoint returns either form.
- web/components/sidebar/BookRecent.tsx: wrap path with apiUrl() — the
  apiFetch swap accidentally dropped the wrapper.
- web/components/space/MemorySection.tsx: restore try/catch error toasts
  in loadMemory and clearMemory (still present in saveMemory and
  refreshMemory; were dropped in load/clear).

Backend (decouple auth from middleware):
- Remove user_context_middleware from api/main.py. It was redundant with
  require_auth (sets the user ContextVar for every protected route) and
  ws_require_auth (sets it for every WebSocket). When AUTH_ENABLED=true and
  a request had no valid token, the middleware fell back to
  local_admin_user() — harmless because require_auth then raised 401, but
  a latent footgun if any code reads the ContextVar before the dependency
  resolves. Removing it makes the auth flow single-pathed and removes the
  "ctx set twice" pattern.
- auth.py: add explicit type annotations to ws_require_auth (returns
  Token | _WsAuthFailed) and the ws_auth_failed sentinel.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 15:43:58 +08:00
mtsui-cmyk
4431e2d4b0 fix: allow quiz answer textarea vertical resize 2026-05-12 15:33:09 +08:00
iwedo
4de4f5e9c9 fix: 系统性修复多用户数据隔离问题
核心问题:
1. HTTP请求的用户上下文仅依赖require_auth依赖,中间件层无保障
2. WebSocket端点(tutorbot/vision_solver/question/knowledge/book)缺少手动认证
3. CoWriterStorage在__init__中固定path_service,单例后路径不再变化
4. get_path_service()静默降级到默认实例,无日志

修复内容:
- 添加user_context_middleware中间件,确保每个HTTP请求都正确设置用户ContextVar
- 添加ws_require_auth()统一WebSocket认证函数,所有WS端点使用
- 修复tutorbot/vision_solver/question/knowledge/book的WebSocket认证
- 统一chat/solve/unified_ws的WebSocket认证为ws_require_auth()
- CoWriterStorage改为@property延迟获取path_service + 按workspace缓存
- get_path_service()降级时输出warning日志
2026-05-12 15:32:57 +08:00
iwedo
a581549e12 fix(multi-user): 修复旧版会话管理器的路径捕获问题,实现完整的数据隔离
核心修改:
- BaseSessionManager: path_service/sessions_file 改为 @property 延迟解析
- chat.py/solve.py: 移除模块级单例,WebSocket 端点添加手动认证
- BookStorage/BookEngine: path_service 延迟解析 + get_book_storage/engine 按路径缓存
- TutorBotManager: path_service 延迟解析 + 修复硬编码 data/tutorbot 路径
- MemoryService: _path_service 改为 @property 延迟解析

修复原理:延迟解析确保路径在请求时(用户上下文已设置)才解析;
按路径缓存确保不同用户获得不同实例,同一用户复用实例。

TutorBot 现在按用户隔离到 multi-user/<uid>/tutorbot/ 而非共享的 data/tutorbot/
2026-05-12 15:32:23 +08:00
WeDone
20c42491a2 fix: replace all fetch() with apiFetch() for authenticated API calls
- Replace fetch() with apiFetch() in 18 files across web/
- Remove redundant credentials: 'include' since apiFetch handles it
- Affected modules: auth, admin, session, skills, book, knowledge,
  notebook, co-writer, playground, agents, sidebar components,
  SaveToNotebookModal, VersionBadge, useTextSource
- Fixes 401 Unauthorized errors in multi-user mode
2026-05-12 15:32:23 +08:00
Bingxi Zhao
06f80c393f Merge pull request #465 from truffle-dev/fix/disable-ssl-verify-sweep
fix(ssl): extend DISABLE_SSL_VERIFY coverage to codex provider and four embedding adapters
2026-05-12 15:28:20 +08:00
Bingxi Zhao
b9dc14c698 Merge pull request #441 from wedone/fix/quiz-question-paragraph-spacing
fix(agents): normalize single newlines to markdown paragraphs in quiz content
2026-05-12 15:28:15 +08:00
unknown
fc4d4f7ca2 fix(H4): add complete_review_task to clean finished tasks from queue 2026-05-12 14:56:59 +08:00
unknown
232f41a446 fix(C1): wrap handler call in try/finally to always save progress 2026-05-12 14:54:22 +08:00
unknown
7af85c5781 fix(H2): deduplicate error records, use RetryAttempt, graduate on correct answer 2026-05-12 14:52:43 +08:00
unknown
325af91a02 fix(C5): use .get() instead of .pop() to avoid mutating request body 2026-05-12 14:51:05 +08:00
unknown
7fb2c11ed1 fix(C2): add _safe_json_parse helper to handle malformed LLM responses 2026-05-12 14:50:02 +08:00
unknown
08e1829fde fix(C4): remove router singleton race condition + use unique tmp filenames in atomic write 2026-05-12 14:45:59 +08:00
unknown
a308e398f2 baseline: snapshot before guided-learning bugfixes 2026-05-12 14:37:28 +08:00
Bingxi Zhao (Frank)
3d5c3a1eb5 improve chat 2026-05-12 02:20:30 +08:00
Bingxi Zhao (Frank)
85779c846b refactor env settings and installation 2026-05-11 12:59:56 +08:00
truffle
93d24f776a fix(ssl): extend DISABLE_SSL_VERIFY coverage to codex provider and four embedding adapters
v1.3.10 added the `openai_http_client.disable_ssl_verify_enabled` helper
and applied it to the SDK paths (`openai_sdk` embedding,
`openai_compat_provider`, `azure_openai_provider`, tutorbot
`openai_compat_provider`). Five raw-httpx call sites still ignored the
flag:

- `provider_core/openai_codex_provider.py:79` hardcoded `verify=True` on
  the first attempt before falling back on `CERTIFICATE_VERIFY_FAILED`.
- `embedding/adapters/openai_compatible.py:193` constructed
  `httpx.AsyncClient(timeout=...)` with no `verify` kwarg.
- `embedding/adapters/jina.py:89`, `ollama.py:61`, `cohere.py:115` same.

Each site now consults the helper and passes `verify=not
disable_ssl_verify_enabled()`. The codex provider's
`CERTIFICATE_VERIFY_FAILED` retry path is preserved unchanged.

Tests:

- `tests/services/embedding/test_disable_ssl_verify.py` (5 adapter tests
  + 1 production-guard test) asserts each adapter passes `verify=False`
  when the flag is set and `verify=True` otherwise.
- `tests/services/llm/test_codex_disable_ssl_verify.py` covers the
  default-true case, flag-flip-to-false case, and the
  retry-on-cert-failure fallback.
2026-05-10 23:08:40 +00:00
Bingxi Zhao (Frank)
ac8f00bd65 prepare v1.3.10 release v1.3.10 2026-05-10 22:56:21 +08:00
Bingxi Zhao (Frank)
df925e6f97 fix lint 2026-05-09 03:11:27 +08:00
Bingxi Zhao (Frank)
72bcdd77d8 prepare v1.3.9 release v1.3.9 2026-05-09 02:53:14 +08:00
Bingxi Zhao
57cd6fe753 Merge pull request #455 from Bortlesboat/codex/tutorbot-nvidia-nim
fix: add TutorBot NVIDIA NIM provider support
2026-05-09 01:57:26 +08:00
Bingxi Zhao
4f7f069ae9 Merge pull request #457 from philliplagoc/feature/sidebar-tooltips
feat: tooltips for sidebar
2026-05-09 01:55:18 +08:00
Bingxi Zhao
accfab92da Merge pull request #452 from wedone/feat/add-zulip-channel
feat(tutorbot): add Zulip channel support
2026-05-09 01:55:03 +08:00