Skip to content

feat: add LiveSpeedGraph setting to toggle between EMA smoothing and raw speed data#340

Merged
SuperCoolPencil merged 4 commits intomainfrom
live-graph
Apr 10, 2026
Merged

feat: add LiveSpeedGraph setting to toggle between EMA smoothing and raw speed data#340
SuperCoolPencil merged 4 commits intomainfrom
live-graph

Conversation

@SuperCoolPencil
Copy link
Copy Markdown
Member

@SuperCoolPencil SuperCoolPencil commented Apr 10, 2026

Greptile Summary

This PR adds a LiveSpeedGraph boolean setting that lets users toggle between raw speed and EMA-smoothed speed in the speed graph. It also ships a collection of related UI quality improvements: truncateString is rewritten to use lipgloss.Width/MaxWidth for correct Unicode terminal-width handling, the label-offset in the focused details panel is corrected from -8 to -12 (matching StatsLabelStyle.Width(12)), description lines in the download list are now truncated, and d.ID receives truncation it was previously missing.

Confidence Score: 5/5

Safe to merge — the feature logic is correct and the accompanying UI fixes are improvements over the previous behavior.

All findings are P2 style suggestions. The core LiveSpeedGraph toggle is implemented correctly, the EMA fallback path is preserved, and the truncation refactor fixes real Unicode-width and overflow bugs.

No files require special attention.

Important Files Changed

Filename Overview
docs/SETTINGS.md Adds live_speed_graph boolean entry to the settings table with accurate description and correct default (false).
internal/config/settings.go Adds LiveSpeedGraph bool field to GeneralSettings with JSON tag, UI labels, and a false default — straightforward and clean.
internal/tui/process.go Correctly gates between raw-speed and EMA paths; nil guard on Settings is appropriate and the first-point fallback (else smoothed = totalSpeed) is preserved for EMA mode.
internal/tui/view.go Refactors truncateString to use lipgloss.Width/MaxWidth for proper Unicode terminal-width handling; corrects the label-offset from -8 to -12 (matching StatsLabelStyle.Width(12)) and adds d.ID truncation.
internal/tui/list.go Extends truncation to description (previously untruncated); adjusts available-width offset to -4 and delegates to the improved truncateString.
internal/tui/components/box.go Replaces custom rune-slice truncation with lipgloss MaxWidth and hoists the style out of the loop; minor "what" comment on the hoisted style variable.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[processProgressMsg] --> B{GraphUpdateInterval elapsed?}
    B -- No --> Z[Skip graph update]
    B -- Yes --> C[calcTotalSpeed]
    C --> D{Settings != nil &&\nLiveSpeedGraph?}
    D -- Yes --> E[smoothed = totalSpeed\n raw speed]
    D -- No --> F{len SpeedHistory > 0?}
    F -- Yes --> G[EMA: α·speed + 1-α·prev\nα = 0.3]
    F -- No --> H[smoothed = totalSpeed\n first-point fallback]
    E --> I[Append to SpeedHistory]
    G --> I
    H --> I
Loading

Comments Outside Diff (1)

  1. internal/tui/process.go, line 54-58 (link)

    P2 Outdated "EMA smoothing" comment

    The outer comment on line 54 still reads "Update speed graph history with EMA smoothing for smooth transitions", but EMA is now only applied when LiveSpeedGraph is false. The comment describes a conditional behaviour as if it were unconditional, and it explains what happens rather than why the two modes exist.

    Rule Used: What: Comments must explain why code exists, not... (source)

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: internal/tui/process.go
    Line: 54-58
    
    Comment:
    **Outdated "EMA smoothing" comment**
    
    The outer comment on line 54 still reads "Update speed graph history with EMA smoothing for smooth transitions", but EMA is now only applied when `LiveSpeedGraph` is `false`. The comment describes a conditional behaviour as if it were unconditional, and it explains *what* happens rather than *why* the two modes exist.
    
    
    
    **Rule Used:** What: Comments must explain *why* code exists, not... ([source](https://app.greptile.com/review/custom-context?memory=4e45ef13-32c2-4753-8060-a44ef767144d))
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
This is a comment left during a code review.
Path: internal/tui/components/box.go
Line: 95-96

Comment:
**"What" comment instead of "why"**

`// Style for truncation` restates what `truncStyle` is without explaining the intent. Per the project's comment guidelines, comments should explain *why* — in this case, why the style is hoisted outside the loop (to avoid allocating a new `lipgloss.Style` on every iteration).

```suggestion
	// Reused across iterations to avoid per-line style allocations
	truncStyle := lipgloss.NewStyle().MaxWidth(innerWidth)
```

**Rule Used:** What: Comments must explain *why* code exists, not... ([source](https://app.greptile.com/review/custom-context?memory=4e45ef13-32c2-4753-8060-a44ef767144d))

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "refactor: optimize box content truncatio..." | Re-trigger Greptile

Comment thread internal/tui/list.go
Comment on lines +145 to +147
// Truncate title and description if needed
// m.Width() is the available space for the list item
availableWidth := m.Width() - 4 // Account for prefix and some padding
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 "What" comment rather than "why"

// m.Width() is the available space for the list item simply restates what the API call returns and doesn't explain the intent behind the -4 offset (e.g. how it accounts for the 2-cell prefix plus a 2-cell safety margin). Per the project's comment guidelines, comments should explain why the code exists.

Suggested change
// Truncate title and description if needed
// m.Width() is the available space for the list item
availableWidth := m.Width() - 4 // Account for prefix and some padding
// Truncate title and description if needed.
// Subtract 4 to leave room for the 2-cell prefix and a 2-cell right margin.
availableWidth := m.Width() - 4

Rule Used: What: Comments must explain why code exists, not... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: internal/tui/list.go
Line: 145-147

Comment:
**"What" comment rather than "why"**

`// m.Width() is the available space for the list item` simply restates what the API call returns and doesn't explain the intent behind the `-4` offset (e.g. how it accounts for the 2-cell prefix plus a 2-cell safety margin). Per the project's comment guidelines, comments should explain *why* the code exists.

```suggestion
	// Truncate title and description if needed.
	// Subtract 4 to leave room for the 2-cell prefix and a 2-cell right margin.
	availableWidth := m.Width() - 4
```

**Rule Used:** What: Comments must explain *why* code exists, not... ([source](https://app.greptile.com/review/custom-context?memory=4e45ef13-32c2-4753-8060-a44ef767144d))

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread internal/tui/components/box.go Outdated
@SuperCoolPencil SuperCoolPencil merged commit d3a7073 into main Apr 10, 2026
15 checks passed
@SuperCoolPencil SuperCoolPencil deleted the live-graph branch April 10, 2026 18:31
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