Skip to content

fix #263: add exception handling for /continue command in stapp#275

Open
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-263-continue-exception
Open

fix #263: add exception handling for /continue command in stapp#275
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/issue-263-continue-exception

Conversation

@Kailigithub
Copy link
Copy Markdown
Contributor

@Kailigithub Kailigithub commented May 6, 2026

问题描述

Issue #263/continue 指令恢复会话时,如果 handle_frontend_commandextract_ui_messages 抛出异常(例如会话文件损坏、后端状态异常等),整个 Streamlit 应用会直接崩溃,用户只能重启。

修复方案

frontends/stapp.py/continue 命令处理流程外层包裹 try/except 块:

  • 捕获所有 Exception 异常
  • 通过 st.error() 显示友好的中文错误提示「恢复会话失败: {异常信息}」
  • 调用 st.rerun() 重新渲染界面,而非直接崩溃

此改动仅增加容错逻辑,不改变正常流程行为。

验证

  • 语法校验:python3 -m py_compile frontends/stapp.py
  • Lint 检查:ruff check frontends/stapp.py ✓(仅有文件头部预存风格问题,与本次修改无关)
  • 改动量:+18 行 / -14 行,精准覆盖 /continue 分支

关联

修复 #263

@Kailigithub
Copy link
Copy Markdown
Contributor Author

问题描述

Issue #263/continue 指令恢复会话时,如果 handle_frontend_commandextract_ui_messages 抛出异常(例如会话文件损坏、后端状态异常等),整个 Streamlit 应用会直接崩溃,用户只能重启。

修复方案

frontends/stapp.py/continue 命令处理流程外层包裹 try/except 块:

  • 捕获所有 Exception 异常
  • 通过 st.error() 显示友好的中文错误提示「恢复会话失败: {异常信息}」
  • 调用 st.rerun() 重新渲染界面,而非直接崩溃

此改动仅增加容错逻辑,不改变正常流程行为。

验证

  • 语法校验:python3 -m py_compile frontends/stapp.py
  • Lint 检查:ruff check frontends/stapp.py ✓(仅有文件头部预存风格问题,与本次修改无关)
  • 改动量:+18 行 / -14 行,精准覆盖 /continue 分支

关联

修复 #263

@Kailigithub Kailigithub force-pushed the fix/issue-263-continue-exception branch from a38d2ef to f05d9a6 Compare May 10, 2026 03:14
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