Skip to content

修复异步初始化中的控制台输入事件循环冲突 - #145

Open
fuilyha56-wq wants to merge 1 commit into
devfrom
fix/async-console-input-event-loop
Open

fuilyha56-wq wants to merge 1 commit into
devfrom
fix/async-console-input-event-loop

Conversation

@fuilyha56-wq

@fuilyha56-wq fuilyha56-wq commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

变更说明

修复 Neo-MoFox 异步启动流程中的事件循环冲突,并理顺控制台快捷键与协议输入交互。

核心修改

  1. 解决事件循环冲突 & 去除重复确认

    • 移除 Bot._initialize_core 中在异步主循环内调用同步控制台输入导致的 asyncio.run() cannot be called from a running event loop 错误。
    • HTTP 安全检查(监听 0.0.0.0 / :: 等通配地址且无强密钥)保留终端 Warning 告警与 UI 状态标记,不再阻塞式二次要求回车确认。
    • 移除未使用的 prompt_console_input 冗余同步函数。
  2. 理顺控制台快捷键

    • 主程序前台运行中按一次 Ctrl+C 直接触发优雅关闭(由后台输入 worker 捕获并向主进程发送 SIGINT,交由 SignalHandler 处理)。
    • 终端日志复制统一由系统终端模拟器处理(如 Ctrl+Shift+C),不再在应用层拦截。
    • 3 秒内第二次 Ctrl+C 保持立即强制退出行为。
  3. 启动鲁棒性增强

    • 启动协议确认(user_agreements.py)增加非交互/非 TTY 环境检查,避免在无控制台重定向场景下无限阻塞。
    • 监听地址采用 ipaddress 判定,完整覆盖 0.0.0.0::::0 等通配绑定场景。
    • 修正启动进度条总步数计数(total_steps=20)。

测试验证

  • uv run pytest test/app/runtime/test_console_input.py test/app/runtime/test_command_parser.py test/app/runtime/test_user_agreements.py test/app/runtime/test_bot_http_security.py -q -p no:cacheprovider -p no:randomly --no-cov
    • 11 passed, 4 skipped
  • uv run ruff check src/app/runtime/ test/app/runtime/ 全部通过。
  • 完整启动主程序验证:HTTP 服务器正常监听,EULA / 遥测自动确认生效,进度推进正常。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

@fuilyha56-wq
fuilyha56-wq changed the base branch from main to dev August 23, 2026 02:32

@minecraft1024a minecraft1024a left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件全是减掉全部再加上全部,我怎么看啊,diff给我弄好了

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哎,你提示词没砍呢

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

什么玩意?这东西为什么要砍prompt喵?

@fuilyha56-wq
fuilyha56-wq force-pushed the fix/async-console-input-event-loop branch from ca7267c to 793196b Compare August 24, 2026 04:16

@KKKKKaoriiiii KKKKKaoriiiii left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doog kool

@KKKKKaoriiiii

Copy link
Copy Markdown
Collaborator

prompt不错,我韩了

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.

3 participants