Skip to content

fix: 文本卡片去重 — 最后一轮输出不再同时出现在文本卡片和结果卡片 - #116

Merged
lishuceo merged 2 commits into
mainfrom
fix/text-card-dedup
Mar 5, 2026
Merged

fix: 文本卡片去重 — 最后一轮输出不再同时出现在文本卡片和结果卡片#116
lishuceo merged 2 commits into
mainfrom
fix/text-card-dedup

Conversation

@lishuceo

@lishuceo lishuceo commented Mar 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • 完成时不将 pendingTurn.textContent 追加到 accumulatedText,文本卡片只展示 turn 1..N-1 的内容,最后一轮由结果卡片独占显示,消除重复
  • 异常路径保留现有行为(无结果卡片时最后一轮仍写入文本卡片)
  • vitest.config.ts 顶部加载 dotenv.config(),测试自动从 .env 读取 API Key

Test plan

  • 发送多轮对话,确认文本卡片不包含最后一轮的总结文本
  • 确认结果卡片正常显示最后一轮内容
  • 确认异常中断时文本卡片仍包含最后可用的输出
  • 运行 npx vitest run 确认测试通过

🤖 Generated with Claude Code

lishuceo and others added 2 commits March 5, 2026 13:19
路由 agent 通过工具搜索 ls 项目目录时,仍会匹配到非仓库目录
(如 talktype-target 编译产物)。即使 use_existing 验证能拒绝,
回退到 use_default 仍不符合预期。

修复: 在搜索指令中明确告知 agent 只有含 .git 的目录才是有效仓库,
编译产物目录不应被选择,部分名称匹配应继续查找更精确的结果。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
完成时不将 pendingTurn.textContent 追加到 accumulatedText,
文本卡片只展示 turn 1..N-1,最后一轮由结果卡片独占显示。
同时 vitest.config.ts 加载 dotenv,测试自动读取 .env 中的 API Key。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented Mar 5, 2026

Copy link
Copy Markdown

Claude finished @lishuceo's task in 55s —— View job


PR Review: Text Card Dedup

  • Check for previous review comments — none found
  • Read changed files and understand context
  • Review changes and provide feedback

Approved — Clean, minimal fix with correct logic.

Analysis

src/feishu/event-handler.ts — The core fix. Two call sites (normal path line 1418, restart path line 1350) now pass undefined instead of pendingTurn?.textContent to flushTextCard(). This means the last turn's text is no longer appended to accumulatedText, so it won't appear in the text card. The result card already displays the final output independently.

Key observations:

  • The onTurn callback (line 1172-1174) still correctly flushes intermediate turns' text into accumulatedText — only the last turn is excluded. This is correct because onTurn fires when a new turn starts, so the last turn's content is never flushed there.
  • The error path (line 1445) correctly preserves the old behavior: flushTextCard(pendingTurn?.textContent, true) — since there's no result card on exception, the last turn's text should still be shown in the text card. This is the right design.

src/claude/router.ts — Prompt refinement for the routing agent to avoid matching build artifact directories (e.g., xxx-target) as valid repos. Requires .git subdirectory check. Reasonable improvement, unrelated to the dedup fix but fine to include.

vitest.config.ts — Loads .env via dotenv.config() so tests can access API keys. Minor concern below.

Minor Note (not blocking)

The vitest.config.ts change loads .env at config time, which means all test runs will have access to real API keys if .env exists. This is fine for integration tests but could lead to accidental real API calls in unit tests if mocks aren't set up properly. Consider whether vitest's built-in envFile option or scoping this to specific test files would be more appropriate. Not a blocker since the test policy already requires .env for some tests.

Verdict

The dedup logic is correct — turns 1..N-1 go to the text card, turn N goes exclusively to the result card, and error paths preserve full visibility. LGTM.

@lishuceo
lishuceo merged commit 2c584cb into main Mar 5, 2026
2 checks passed
@lishuceo
lishuceo deleted the fix/text-card-dedup branch March 5, 2026 05:54
lishuceo added a commit that referenced this pull request Apr 8, 2026
* fix: 路由 prompt 搜索指令要求验证 .git 目录

路由 agent 通过工具搜索 ls 项目目录时,仍会匹配到非仓库目录
(如 talktype-target 编译产物)。即使 use_existing 验证能拒绝,
回退到 use_default 仍不符合预期。

修复: 在搜索指令中明确告知 agent 只有含 .git 的目录才是有效仓库,
编译产物目录不应被选择,部分名称匹配应继续查找更精确的结果。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: 文本卡片去重 — 最后一轮输出不再同时出现在文本卡片和结果卡片

完成时不将 pendingTurn.textContent 追加到 accumulatedText,
文本卡片只展示 turn 1..N-1,最后一轮由结果卡片独占显示。
同时 vitest.config.ts 加载 dotenv,测试自动读取 .env 中的 API Key。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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