Skip to content

fix: 叙事简报全书进度恒为 1%(life_cycle.progress 单位换算遗漏) - #212

Open
uwakeme wants to merge 2 commits into
shenminglinyi:masterfrom
uwakeme:fix/narrative-brief-progress-unit
Open

uwakeme wants to merge 2 commits into
shenminglinyi:masterfrom
uwakeme:fix/narrative-brief-progress-unit

Conversation

@uwakeme

@uwakeme uwakeme commented Sep 26, 2026 •

Copy link
Copy Markdown

变更类型

  • fix Bug 修复

变更说明

两处进度类字段的单位换算遗漏——后端返回 01 分数,前端直接当 0100 百分数显示,导致写完的书进度恒显示 0~1%:

  1. 叙事简报面板(NarrativeDashboardPanel):life_cycle.progress(0~1)被 Math.round(p) 直接展示,写完的书(1.0)显示「进度 1%」。同仓库 StoryNavigator.vue 对同一字段已按 Math.round(progress * 100) 处理,本修复与其对齐,并钳制到 100。
  2. 顶部统计栏(StatsTopBar):统计接口的 completion_rate 在后端模型中明确注释为 "Fraction of book completed (0.0 to 1.0)"(stats_models.py),面板却把原始分数 toFixed 后直接拼 % 号——完成的书显示「完成率 1.0%」。已乘 100 再格式化。

两处均为纯展示换算,后端语义不动。


架构影响

  • 涉及层级:仅 frontend(两个文件各一处 computed/格式化,无新增文件)
  • 是否新增数据库表/字段:否
  • 是否修改现有 API 契约(路径/字段/类型变更):否(纯前端展示换算,后端 0~1 语义保持不变)

测试

cd frontend && npx vue-tsc --noEmit
# 通过(无类型错误)
  • 换算逻辑与仓库内既有正确实现(StoryNavigator)一致;全仓检索确认 life_cycle.progress 与 completion_rate 无其他展示点遗漏

Summary by CodeRabbit

  • Bug Fixes
    • Corrected progress display so fractional lifecycle values appear as percentages, rounded and capped at 100%.
    • Corrected completion-rate display to convert fractional values to percentages and format them to one decimal place.

life_cycle.progress is a 0..1 fraction (as StoryNavigator already
assumes via Math.round(progress * 100)), but NarrativeDashboardPanel
rounded it directly, so a finished book (1.0) displayed as 进度 1% and
every value below 0.5% as 0%. Scale to percent and clamp.
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f9a7fa2a-3762-4676-b38b-5c70fedd40f6

📥 Commits

Reviewing files that changed from the base of the PR and between dba27ce and 5683a3d.

📒 Files selected for processing (1)
  • frontend/src/components/stats/StatsTopBar.vue

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Lifecycle progress and completion-rate displays now convert fractional values to percentages. Lifecycle progress is rounded and capped at 100. Completion rate is formatted to one decimal place.

Changes

Percentage displays

Layer / File(s) Summary
Convert fractional values for display
frontend/src/components/workbench/NarrativeDashboardPanel.vue, frontend/src/components/stats/StatsTopBar.vue
progressPct multiplies lifecycle progress by 100, rounds it, and caps it at 100. The completion-rate display multiplies the rate by 100 before formatting it to one decimal place.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 5683a

The percentage display fixes are consistent with the available API and lifecycle contracts, with no concrete merge-blocking risk identified.

Architecture Summary

Architecture risk: 🔵 Low · up to 5683a

The change affects 1 system.

Changed systems: frontend

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — frontend (ui) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in frontend/src/components/workbench/NarrativeDashboardPanel.vue: progressPct now converts the lifecycle progress fraction to a rounded percentage and caps it at 100; previously it returned the rounded raw value.
  • observed — Modified behavior in frontend/src/components/stats/StatsTopBar.vue: The displayed completion rate is now calculated as rate * 100 before one-decimal formatting; previously, the raw rate was formatted directly.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
Title check ✅ Passed The title clearly identifies the bug and the missing unit conversion for whole-book progress. It accurately summarizes the main change, although it does not mention the related StatsTopBar fix.
Description check ✅ Passed The description covers the fix, affected frontend components, architecture impact, API impact, and type-check result. It omits the required 风险说明 section and does not provide the required frontend buil…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

Same unit mismatch as the narrative brief panel: the stats API's
completion_rate is documented (stats_models.py) as "Fraction of book
completed (0.0 to 1.0)", but StatsTopBar formatted the raw fraction
with a percent sign, so a finished book (1.0) displayed as 1.0%.
Scale to percent before formatting.
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