Skip to content

Fix #3: persist session history and add session listing - #10

Open
xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-3-session-history
Open

xiaoyao-666-coder wants to merge 2 commits into
zhengdaodeguL:mainfrom
xiaoyao-666-coder:fix/issue-3-session-history

Conversation

@xiaoyao-666-coder

Copy link
Copy Markdown

Closes #3.

刷新或登出重登后会话历史全部丢失。根因:前端消息只在 React 内存里,后端没有列会话的接口,会话状态也不存完整对话记录。

  • 后端:会话状态存下每轮问答(messages),新增 GET /api/sessions(仅本人、按更新时间倒序),GET /api/sessions/{id} 返回完整消息。
  • 前端:左栏改为真实历史列表,登录/刷新后默认恢复最近的会话,点击旧会话可恢复完整对话;空列表时才新建会话。
  • 新增 backend/tests/test_session_history.py(7 个测试):多轮存入与恢复、列表倒序且仅本人、跨用户读他人会话 404、过期会话排除、幂等重放不重复。

验证:MEDGUIDE_MODE=test python -m pytest -q backend/tests 528 passed(基线 521 + 7 新);前端 npm test 10/10,npm run build 成功。

已知限制:Redis 后端没有会话索引,历史列表在 Redis 部署下返回 complete: false(内存后端完整可用);会话默认 24 小时过期、重启丢失的原有存储模型未改。

- Store per-turn messages in WorkflowState and include them in
  the public session state, so refresh/logout no longer loses the
  transcript.
- Add GET /api/sessions (owner-scoped, newest first) and include
  messages in GET /api/sessions/{id}.
- Frontend: show a real history list, restore the most recent
  session on login/refresh, and restore a session on click.
- Add backend/tests/test_session_history.py (7 tests).

Closes zhengdaodeguL#3 (session history lost on refresh/logout).
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.

[Bug][严重] 刷新或登出重登后会话历史全部丢失

1 participant