Skip to content

fix(issue#40,#41): escape prompt-variable braces + overlay close overlap - #42

Merged
modusensus merged 1 commit into
mainfrom
fix/issue-40-41
Aug 31, 2026
Merged

modusensus merged 1 commit into
mainfrom
fix/issue-40-41

Conversation

@modusensus

Copy link
Copy Markdown
Member

修复内容

issue #40 — 记忆内容含 {{...}} 模板语法时整轮崩溃

DSH 核心 interpolate() 会把 {{name}} 当 prompt 变量严格校验(变量名须匹配 /^[a-z][a-z0-9_]*$/),记忆里合法的模板语法(如 {{hl|}}、{{挖空}}、{{关键词}})因非法变量名直接 throw,整轮失败。

修复:注入边界做 run-based 花括号转义({{a}}→{\{a\}\}),连续 2+ 个花括号之间插反斜杠,奇数连续(如 {{{a}}})也不残留字面 {{,interpolate() 不再扫描到。覆盖 memory 块 / 短期上下文 / 用户设置三处注入出口,新增配置 escapePromptVariables(默认开,关闭时原样透传)。转义幂等、单花括号不受影响。

issue #41 — 记忆窗口关闭按钮重叠无法关闭

MemoryOverlay 全屏覆盖层顶栏右侧的关闭按钮,与宿主窗口标题栏控制按钮(最小化/最大化/关闭)落在同一区域,宿主控制按钮浮在 web 内容最上层,抢走关闭按钮点击热区。

修复:顶栏改为左对齐(标题 + 关闭按钮并排),关闭按钮离开右上角宿主控制按钮区,任何窗口尺寸下都可见可点。

验证

  • 新增 6 个测试(含 {{{a}}} 奇数括号回归)
  • 全量 782/782 测试通过

Fixes #40, #41

🤖 Generated with Claude Code

- #40: run-based brace escaping at the injection boundary ({{→{\{、}}→\}\}),
  covers odd runs like {{{a}}}; gated by escapePromptVariables (default on)
  so DSH interpolate() never sees an illegal {{...}} to throw on
- #41: MemoryOverlay top bar left-aligned, close button clears the host
  window-control cluster (min/max/close) and stays clickable

Co-Authored-By: Claude <[email protected]>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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] 记忆内容含 {{hl|}} 等模板语法时整轮失败:malformed prompt variable reference "{{hl|}}" in context "memory"

3 participants