Skip to content

fix(agent): resolve dream report locale before prompting - #49

Open
moonrailgun wants to merge 3 commits into
mainfrom
dream-report
Open

fix(agent): resolve dream report locale before prompting#49
moonrailgun wants to merge 3 commits into
mainfrom
dream-report

Conversation

@moonrailgun

@moonrailgun moonrailgun commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Background

Dream report generation could read the current locale before i18n initialization, causing daily and weekly LLM prompts to use the wrong output language.

Changes

  • Initialize i18n before resolving the daily dream report locale.
  • Inject the resolved locale into daily and weekly system prompts as the authoritative output locale.
  • Update weekly dream generation to use the same resolved locale in both system and user prompts.
  • Improve dream history summaries for legacy and structured recap data.
  • Add UI refinements for heatmap positioning, duration formatting, and history item states.

Testing

Updated WebUI tests cover locale initialization, prompt locale injection, heatmap scrolling, localized duration formatting, and history summary selection.

Summary by CodeRabbit

  • New Features
    • Duration labels now display localized hours and minutes.
    • Dream reports consistently follow the selected application language.
    • Heatmaps automatically scroll to the latest entries after loading.
    • Added localized activity-duration tooltips with keyboard and pointer support.
    • History summaries prioritize structured recap information when available.
    • Improved hover and selection styling for history items.
  • Bug Fixes
    • Improved handling of unavailable duration data and tooltip dismissal.
    • Corrected locale initialization for reliable translated report content.
    • Fixed recap, duration formatting, and language consistency across reports.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 78ae695e-6e87-4608-9151-da7cb3ff42cd

📥 Commits

Reviewing files that changed from the base of the PR and between acb9b87 and 60f599c.

📒 Files selected for processing (2)
  • src/dao/browser/ui/webui/resources/agent/__tests__/dao_dream_app.test.ts
  • src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/dao/browser/ui/webui/resources/agent/tests/dao_dream_app.test.ts
  • src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts

📝 Walkthrough

Walkthrough

The PR makes Dream runners use initialized locales for prompt generation. It adds locale-aware dates, durations, heatmap tooltips, structured recap tracking, history-summary precedence, heatmap positioning, styling, tests, and documentation.

Changes

Dream localization and recap

Layer / File(s) Summary
Authoritative runner locale
src/dao/browser/ui/webui/resources/agent/dao_dream_runner.ts, src/dao/browser/ui/webui/resources/agent/dao_weekly_dream_runner.ts, src/dao/browser/ui/webui/resources/agent/__tests__/dao_dream_runner.test.ts, src/dao/browser/ui/webui/resources/agent/__tests__/dao_weekly_dream_runner.test.ts
Both runners initialize i18n before prompt construction and inject the resolved locale into system and user prompts. Tests verify asynchronous initialization and French locale propagation.
Recap presentation and heatmap behavior
src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts
The app formats dates and durations with the active locale, adds accessible heatmap tooltips, handles unavailable duration data, scrolls to recent entries, tracks structured recaps, selects history summaries, and updates styling.
Recap validation and localization support
src/dao/browser/ui/webui/resources/agent/__tests__/dao_dream_app.test.ts, src/dao/browser/ui/webui/resources/agent/i18n/locales/en.ts, src/dao/browser/ui/webui/resources/agent/i18n/locales/zh-CN.ts, docs/feature-checklist.md, docs/features.md
Tests cover localized dates, duration tooltips, dismissal behavior, legacy reports, heatmap scrolling, summary precedence, and measured rhythm durations. Locale resources and documentation define the tooltip behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DreamRunner
  participant i18n
  participant PromptRequest
  DreamRunner->>i18n: Initialize localization
  DreamRunner->>i18n: Read active locale
  DreamRunner->>PromptRequest: Add locale to system and user prompts
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: resolving the dream report locale before prompt generation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dream-report

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts (1)

1599-1609: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

不要让 Markdown 回退主题覆盖结构化摘要。

recap.summary 非空但 recap.themes 没有有效项时,Line 1601 会将报告标记为结构化报告。Line 1602 至 Line 1610 随后会从 Markdown 添加回退主题。Line 2294 会优先显示该回退主题标题,而不是 recap.summary

在添加 Markdown 回退主题前,单独记录是否存在有效的结构化主题。只有有效的结构化主题才应优先于结构化摘要。添加“有 summary、无有效 recap.themes、Markdown 含标题”的历史列表测试。

Also applies to: 2289-2297

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts` around lines 1599
- 1609, 在 recap 解析流程中单独记录 recap.themes 是否包含有效结构化主题,不要用同时包含 summary 的
hasStructuredRecap 作为主题优先级判断;更新 Markdown 回退主题及 2289-2297 附近的展示逻辑,使仅有
recap.summary、没有有效结构化主题时始终优先显示摘要,而只有有效结构化主题才能覆盖摘要。补充“有 summary、无有效
recap.themes、Markdown 含标题”的历史列表测试。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts`:
- Around line 1599-1609: 在 recap 解析流程中单独记录 recap.themes 是否包含有效结构化主题,不要用同时包含
summary 的 hasStructuredRecap 作为主题优先级判断;更新 Markdown 回退主题及 2289-2297 附近的展示逻辑,使仅有
recap.summary、没有有效结构化主题时始终优先显示摘要,而只有有效结构化主题才能覆盖摘要。补充“有 summary、无有效
recap.themes、Markdown 含标题”的历史列表测试。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a050f810-ab48-4fdb-a516-b83d01fb9d3e

📥 Commits

Reviewing files that changed from the base of the PR and between cb424bd and acb9b87.

📒 Files selected for processing (6)
  • docs/feature-checklist.md
  • docs/features.md
  • src/dao/browser/ui/webui/resources/agent/__tests__/dao_dream_app.test.ts
  • src/dao/browser/ui/webui/resources/agent/dao_dream_app.ts
  • src/dao/browser/ui/webui/resources/agent/i18n/locales/en.ts
  • src/dao/browser/ui/webui/resources/agent/i18n/locales/zh-CN.ts

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