WeKnora/frontend/src/utils
wizardchen 921e4c015a fix(agent): hide trailing thinking event when it duplicates final answer
The natural-stop path on the backend (observe.go Case 1) emits the same
content twice: once as streaming thinking chunks (from
streamThinkingToEventBus's per-chunk callback) which the frontend merges
into a single thinking event, and once as one big EventAgentFinalAnswer.
The result is that the intermediate-steps tree contains a thinking card
whose content is identical to the answer card rendered below it.

Detect this duplication and hide the offending thinking event from the
tree:

- New utils `normaliseForComparison` and `thinkingEqualsAnswer` perform
  a tolerant comparison: strip <think>…</think> blocks (which leak into
  raw thinking chunks but not into the post-StripThinkBlocks answer),
  strip final-answer wrappers, collapse whitespace, then exact-equal or
  ±2% length with matching head/tail.
- `hiddenThinkingEventIds` (replacing the previous single-id
  `promotedThinkingEventId`) now collects two cases of duplicate
  thinking: the legacy promotion fallback (no answer event present) and
  the natural-stop content-match case.

The final_answer-tool path is unaffected because reasoning thinking
events ("我找到了…让我整理…") and the answer payload have different
content and don't match the equivalence check.
2026-05-07 17:33:03 +08:00
..
api-base.ts feat(frontend): respect BASE_URL so the SPA works behind a path-prefix reverse proxy 2026-05-05 00:58:19 +08:00
caret.ts feat: 支持输入框内选择知识库和文件,优化选择交互体验 2025-12-22 13:11:31 +08:00
chatMessageShared.ts feat(i18n): replace hardcoded Chinese strings with i18n calls across frontend 2026-03-06 10:34:08 +08:00
cronHumanize.ts feat(datasource): implement data source management functionality 2026-03-30 20:46:07 +08:00
files.ts fix(frontend): knowledge document list layout, batch bar, and selection 2026-04-29 15:20:41 +08:00
finalAnswer.ts fix(agent): hide trailing thinking event when it duplicates final answer 2026-05-07 17:33:03 +08:00
index.ts feat(video): remove video upload support and update related terminology 2026-04-14 22:59:14 +08:00
mermaidShared.ts fix(frontend): prevent duplicate click binding 2026-03-30 10:46:50 +08:00
mermaidViewer.ts feat(i18n): replace hardcoded Chinese strings with i18n calls across frontend 2026-03-06 10:34:08 +08:00
request.ts feat(request): enhance token refresh handling and public auth request logic 2026-04-15 15:58:01 +08:00
security.ts fix(security): forbid <style> in sanitized document HTML 2026-05-06 16:41:20 +08:00
tdesign-icon-offline.ts fix(frontend): bundle tdesign-icons sprite locally for offline deploys 2026-04-23 18:21:49 +08:00
tool-capabilities.ts feat: Enhance agent tool compatibility and knowledge base filtering 2026-04-23 17:28:00 +08:00
tool-icons.ts feat: friendly display for MCP tool names in frontend (#715) 2026-03-21 10:22:05 +08:00