renderStoryTimings renders the per-story timing list with mini bar charts.
(innerWidth int)
| 322 | |
| 323 | // renderStoryTimings renders the per-story timing list with mini bar charts. |
| 324 | func (c *CompletionScreen) renderStoryTimings(innerWidth int) string { |
| 325 | var b strings.Builder |
| 326 | |
| 327 | checkStyle := lipgloss.NewStyle().Foreground(SuccessColor) |
| 328 | titleStyle := lipgloss.NewStyle().Foreground(TextColor) |
| 329 | dotStyle := lipgloss.NewStyle().Foreground(MutedColor) |
| 330 | durStyle := lipgloss.NewStyle().Foreground(TextColor) |
| 331 | barStyle := lipgloss.NewStyle().Foreground(SuccessColor) |
| 332 | |
| 333 | // Find max duration for proportional bars |
| 334 | var maxDur time.Duration |
| 335 | for _, st := range c.storyTimings { |
| 336 | if st.Duration > maxDur { |
| 337 | maxDur = st.Duration |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | maxBarWidth := 10 |
| 342 | // Layout: "✓ " + title + " " + dots + " " + duration + " " + bar |
| 343 | // Reserve: 2 (check+space) + 1 (space before dots) + 1 (space after dots) + 8 (duration) + 2 (gap) + bar |
| 344 | fixedWidth := 2 + 1 + 1 + 8 + 2 + maxBarWidth |
| 345 | maxTitleWidth := innerWidth - fixedWidth |
| 346 | if maxTitleWidth < 10 { |
| 347 | maxTitleWidth = 10 |
| 348 | } |
| 349 | |
| 350 | // Limit visible stories |
| 351 | maxVisible := c.height - 16 |
| 352 | if maxVisible < 3 { |
| 353 | maxVisible = 3 |
| 354 | } |
| 355 | visible := c.storyTimings |
| 356 | truncated := 0 |
| 357 | if len(visible) > maxVisible { |
| 358 | truncated = len(visible) - maxVisible |
| 359 | visible = visible[:maxVisible] |
| 360 | } |
| 361 | |
| 362 | for _, st := range visible { |
| 363 | // Truncate title if needed |
| 364 | title := st.Title |
| 365 | titleLen := lipgloss.Width(title) |
| 366 | if titleLen > maxTitleWidth { |
| 367 | title = title[:maxTitleWidth-1] + "…" |
| 368 | titleLen = maxTitleWidth |
| 369 | } |
| 370 | |
| 371 | // Duration string (right-aligned in 8 chars) |
| 372 | durStr := formatDuration(st.Duration) |
| 373 | if len(durStr) > 8 { |
| 374 | durStr = durStr[:8] |
| 375 | } |
| 376 | |
| 377 | // Dot leaders |
| 378 | dotCount := innerWidth - 2 - titleLen - 1 - len(durStr) - 2 - maxBarWidth - 1 |
| 379 | if dotCount < 2 { |
| 380 | dotCount = 2 |
| 381 | } |
no test coverage detected