Skip to content

[6228] 插件协议读取兼容 R7RS read-line,修复 goldfish 18.11.40 起插件永久阻塞 - #4756

Merged
PinkMagicFly merged 1 commit into
mainfrom
pigmagicfly/6228/plugin-protocol-r7rs-readline
Oct 21, 2026
Merged

PinkMagicFly merged 1 commit into
mainfrom
pigmagicfly/6228/plugin-protocol-r7rs-readline

Conversation

@PinkMagicFly

Copy link
Copy Markdown
Contributor

关联任务

  • 任务文档:LiiiLabs/dev-agent#230(devel/6228.stem)

概要

修复 Goldfish Scheme 18.11.40 起所有 Goldfish 插件「读完请求后永久阻塞」的问题。

  • Goldfish 18.11.40 将 stdin read-line 规范为 R7RS 语义,行尾不再保留 \n。旧协议读取循环硬编码匹配 "<EOF>\n",导致插件无法检测到段末标记,阻塞在下一次 read-line,主进程等待超时、GUI 持续转圈;同时逐行拼接多行输入时丢失换行符。

改动点

  1. TeXmacs/plugins/goldfish/goldfish/texmacs/protocol.scm:
    • 新增 read-paragraph-line-with-eol:行尾缺少换行符时自动补齐 \n,保证新旧 Goldfish 版本行为一致,多行代码拼接不粘连;
    • 新增 read-paragraph-eof-marker?:兼容 "<EOF>"、"<EOF>\n"、"<EOF>\r"、"<EOF>\r\n" 四种段末标记形态;
    • 重构 read-paragraph-by-visible-eof 主循环。
  2. TeXmacs/plugins/gnuplot/goldfish/tm-gnuplot.scm:
    • gnuplot-read-code 移除本地循环,改调 (read-paragraph-by-visible-eof)。
  3. TeXmacs/plugins/quiver/goldfish/tm-quiver.scm:
    • quiver-read-code 移除本地循环,改调 (read-paragraph-by-visible-eof)。
  4. TeXmacs/plugins/tikz/goldfish/tm-tikz.scm:
    • tikz-read-code 移除本地循环,改调 (read-paragraph-by-visible-eof)。
  5. TeXmacs/plugins/llm/progs/llm/tests/chat-protocol-test.scm:
    • 引入 (texmacs protocol),新增 test-read-paragraph-eof-marker 覆盖多行段落拼接、空段落与连续空行场景。

验收验证

  • gf fmt --check:通过。
  • xmake build --yes stem && xmake install --yes stem:构建与安装通过。
  • xmake r chat-protocol-test:64 correct, 0 failed(原 61 项 + 新增 3 项全部通过)。
  • 无头冒烟验证:printf '(* 2 3)\n<EOF>\n' | gf /tmp/gf-fix-check/run.scm default 成功回显 ^Bscheme:(goldfish-result "6")^E。
  • 会话与插件手动回归:Goldfish Scheme 会话、Telemetry 遥测事件上报等均正常。
  • git diff 严格局限于上述 5 个文件,无 src/ 与 3rdparty/s7/ 改动。

@da-liii da-liii 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.

LGTM

@PinkMagicFly
PinkMagicFly merged commit 0cf207c into main Oct 21, 2026
3 checks passed
@PinkMagicFly
PinkMagicFly deleted the pigmagicfly/6228/plugin-protocol-r7rs-readline branch October 21, 2026 09:45
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.

2 participants