Skip to content

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

Merged
moonrailgun merged 4 commits into
mainfrom
dream-report
Aug 12, 2026
Merged

fix(agent): resolve dream report locale before prompting#49
moonrailgun merged 4 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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 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 identifies the primary fix: 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

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/dao/browser/ui/webui/resources/agent/__tests__/dao_dream_app.test.ts`:
- Around line 546-547: 收紧 dao_dream_app 热图测试中的 class="heat-cell" 数量断言,将
toBeGreaterThan(350) 提高为至少大于 364,以验证完整年度的日期单元格数量。
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: dfe1deaf-51d9-450f-82f5-eaf9a90fb897

📥 Commits

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

📒 Files selected for processing (1)
  • src/dao/browser/ui/webui/resources/agent/__tests__/dao_dream_app.test.ts

Comment on lines +546 to +547
expect(countTemplateMarkers(template, 'class="heat-cell"'))
.toBeGreaterThan(350);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

收紧完整一年的热图断言。

toBeGreaterThan(350) 仍允许缺少多个日期单元格,因此不能验证完整一年。生产实现至少生成 365 个单元格。请将阈值提高到 364 以上,或按固定结束日期断言精确数量。

建议修改
        expect(countTemplateMarkers(template, 'class="heat-cell"'))
-           .toBeGreaterThan(350);
+           .toBeGreaterThan(364);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(countTemplateMarkers(template, 'class="heat-cell"'))
.toBeGreaterThan(350);
expect(countTemplateMarkers(template, 'class="heat-cell"'))
.toBeGreaterThan(364);
🤖 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/__tests__/dao_dream_app.test.ts`
around lines 546 - 547, 收紧 dao_dream_app 热图测试中的 class="heat-cell" 数量断言,将
toBeGreaterThan(350) 提高为至少大于 364,以验证完整年度的日期单元格数量。

@moonrailgun
moonrailgun merged commit 1160197 into main Aug 12, 2026
2 checks passed
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