Skip to content

v0.1.5: enriched JSON, refresh indicator, slower sampling, bits label#24

Merged
programmersd21 merged 1 commit into
mainfrom
feat/v0.1.5
Jul 8, 2026
Merged

v0.1.5: enriched JSON, refresh indicator, slower sampling, bits label#24
programmersd21 merged 1 commit into
mainfrom
feat/v0.1.5

Conversation

@programmersd21

@programmersd21 programmersd21 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Closes #19, #20, #21, #22

  • Enrich --once --json output with status, timestamp, download_human, upload_human
  • Show refresh interval in footer when non-default (persistent, not fleeting)
  • Add 30s, 60s, 300s sampling intervals for overnight monitoring
  • Show [bits] label in footer when bits mode is active

Summary by Sourcery

Extend one-shot JSON output and the TUI footer to expose more context (status, timing, units, and refresh interval) and support slower sampling for long-running monitoring.

New Features:

  • Enrich one-shot JSON output with status, timestamp, and human-readable download/upload rates.
  • Display a persistent footer indicator for non-default refresh intervals.
  • Add longer refresh intervals (up to 5 minutes) for extended monitoring sessions.
  • Show a footer label when bits mode is active to distinguish from bytes mode.

Documentation:

  • Document the 0.1.5 changes in the changelog, including JSON, refresh indicator, sampling intervals, and bits label.

Summary by CodeRabbit

  • New Features

    • Added more fields to one-shot JSON output, including status, timestamp, and human-readable transfer rates.
    • Expanded the UI footer to show bits mode and the current refresh interval when it differs from the default.
    • Broadened refresh interval options, including longer sampling windows.
  • Bug Fixes

    • Improved consistency between displayed metrics and exported JSON snapshot data.
  • Chores

    • Updated the app version to 0.1.5 and added a new release entry.

@programmersd21 programmersd21 merged commit 056d225 into main Jul 8, 2026
@programmersd21 programmersd21 deleted the feat/v0.1.5 branch July 8, 2026 10:57
@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds enriched JSON output for one-shot runs, exposes non-default refresh intervals and bits mode in the UI footer, extends available sampling intervals up to 5 minutes, and bumps the version and changelog for v0.1.5.

File-Level Changes

Change Details Files
Enrich one-shot JSON output with status, timestamp, and human-readable throughput fields.
  • Compute formatted download and upload rates using ui.FormatBpsExt before building the JSON object.
  • Extend the JSON map to include status, RFC3339 timestamp, interface, raw bps values, human-readable throughput strings, peak values, and unit_display.
  • Keep JSON pretty-printing behavior unchanged while expanding the payload schema.
cmd/flow/main.go
Show bits mode and non-default refresh interval in the dashboard footer.
  • Append a muted "[bits]" marker to the interface string when bits mode is active.
  • Append a muted formatted refresh interval string when the refresh interval differs from the 100ms default.
  • Introduce a formatInterval helper that renders refresh intervals as "every Xms" or "every Xs" depending on duration.
internal/ui/views.go
Extend refresh interval presets to support slower sampling for long-running monitoring.
  • Augment the refresh interval options slice with additional slower durations (3s, 5s, 10s, 30s, 60s, 300s) in adjustRefreshInterval.
  • Preserve existing faster intervals while enabling overnight-friendly sampling cadences.
internal/ui/model.go
Document and version the v0.1.5 release.
  • Add a 0.1.5 changelog entry describing enriched JSON output, footer refresh interval display, extended sampling intervals, and bits mode labeling.
  • Update the VERSION file to reflect the 0.1.5 release.
CHANGELOG.md
VERSION

Assessment against linked issues

Issue Objective Addressed Explanation
#19 Add status and timestamp fields to the flow --once --json snapshot output so each snapshot is self-contained.
#19 Add human-readable download and upload fields (download_human, upload_human) while preserving existing numeric JSON fields.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 28cbdc09-78a0-4a1a-a857-ff41c18a99ff

📥 Commits

Reviewing files that changed from the base of the PR and between beb2c9e and e93df20.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • VERSION
  • cmd/flow/main.go
  • internal/ui/model.go
  • internal/ui/views.go

📝 Walkthrough

Walkthrough

Enriches --once --json output with status, timestamp, download_human, and upload_human fields; extends selectable refresh interval durations in the TUI; adds footer indicators for bits mode and non-default refresh intervals; updates changelog and version to 0.1.5.

Changes

Flow 0.1.5 feature updates

Layer / File(s) Summary
Enriched JSON snapshot output
cmd/flow/main.go
runOnce's --json output now includes status, timestamp (RFC3339), download_human, and upload_human alongside existing numeric bps and peak fields.
Refresh interval options and footer indicators
internal/ui/model.go, internal/ui/views.go
Refresh interval selection now supports additional durations (3s–300s); a new formatInterval helper formats durations for display; footer text shows [bits] when bits mode is active and an every ... interval hint when the refresh interval is non-default.
Changelog and version bump
CHANGELOG.md, VERSION
Adds a 0.1.5 changelog entry summarizing the new JSON fields, footer refresh display, extended sampling range, and bits indicator; bumps VERSION to 0.1.5.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/v0.1.5

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

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request enriches the JSON snapshot output with status, timestamp, and human-readable download/upload speeds, extends the sampling range for refresh intervals up to 5 minutes, and displays the active refresh interval and bits mode indicator in the footer. The feedback suggests using integer division instead of floating-point conversion for formatting intervals, resolving a potential inconsistency in the JSON output where raw numeric values remain in bytes/sec while the display unit is in bits, and replacing a hardcoded default refresh interval with a constant to improve maintainability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread internal/ui/views.go
Comment on lines +711 to +713
if d >= time.Second {
return fmt.Sprintf("every %ds", int(d.Seconds()))
}

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.

medium

Using int(d.Seconds()) involves floating-point conversion, which is less idiomatic in Go and can theoretically lead to precision issues. It is more idiomatic and precise to use integer division: int(d / time.Second).

Suggested change
if d >= time.Second {
return fmt.Sprintf("every %ds", int(d.Seconds()))
}
if d >= time.Second {
return fmt.Sprintf("every %ds", int(d/time.Second))
}

Comment thread cmd/flow/main.go
Comment on lines +186 to +192
"download_bps": s.DownBps,
"upload_bps": s.UpBps,
"download_human": down,
"upload_human": up,
"peak_down_bps": s.DownBps,
"peak_up_bps": s.UpBps,
"unit_display": autoUnitExt(s.DownBps, bits),

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.

medium

When bits mode is active, unit_display returns a bits-based unit (e.g., Gb/s), and download_human displays the speed in bits/sec. However, download_bps, upload_bps, peak_down_bps, and peak_up_bps still contain the raw bytes/sec values (s.DownBps and s.UpBps). This creates an inconsistency in the JSON output where the raw numeric values do not match the unit specified in unit_display. Consider scaling these numeric values by 8 when bits is true, or renaming/adding separate fields to clarify the unit.

Comment thread internal/ui/views.go
Comment on lines +452 to +454
if m.refreshInterval != 100*time.Millisecond {
ifaceStr += theme.Muted().Render(" " + formatInterval(m.refreshInterval))
}

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.

medium

The default refresh interval of 100 * time.Millisecond is hardcoded here. If the default refresh interval is changed in the configuration or another part of the codebase in the future, this check will become out of sync. Consider defining a constant for the default refresh interval (e.g., in the config package or as a package-level constant) and referencing it here to improve maintainability.

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

Hey - I've found 1 issue, and left some high level feedback:

  • The JSON snapshot timestamp is generated with a fresh time.Now() rather than being coupled to the sample, which could drift if the sampling ever moves; consider sourcing or passing through the actual sample time so the JSON reflects when the measurement was taken.
  • The default refresh interval 100*time.Millisecond is now hard-coded in dashboardContentLines while the set of intervals lives in adjustRefreshInterval; consider centralizing the default interval value (e.g., a shared constant) to avoid divergence if the default changes in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The JSON snapshot timestamp is generated with a fresh `time.Now()` rather than being coupled to the sample, which could drift if the sampling ever moves; consider sourcing or passing through the actual sample time so the JSON reflects when the measurement was taken.
- The default refresh interval `100*time.Millisecond` is now hard-coded in `dashboardContentLines` while the set of intervals lives in `adjustRefreshInterval`; consider centralizing the default interval value (e.g., a shared constant) to avoid divergence if the default changes in the future.

## Individual Comments

### Comment 1
<location path="internal/ui/views.go" line_range="452-453" />
<code_context>
+		if m.bitsMode {
+			ifaceStr += theme.Muted().Render("  [bits]")
+		}
+		if m.refreshInterval != 100*time.Millisecond {
+			ifaceStr += theme.Muted().Render("  " + formatInterval(m.refreshInterval))
+		}

</code_context>
<issue_to_address>
**suggestion:** Avoid hard-coding the 100ms default refresh interval in the view layer

Using `100*time.Millisecond` here couples the UI to a specific default. If that default changes, this condition will drift out of sync. Please reference a shared constant (or a model field) instead so changes to the default automatically stay consistent with the display logic.

Suggested implementation:

```golang
		if m.refreshInterval != defaultRefreshInterval {
			ifaceStr += theme.Muted().Render("  " + formatInterval(m.refreshInterval))
		}

```

```golang
const defaultRefreshInterval = 100 * time.Millisecond

func formatInterval(d time.Duration) string {

```

If your project already defines a canonical default refresh interval (e.g. in a config or model package), you should:
1. Remove the newly added `defaultRefreshInterval` constant from `views.go`.
2. Import and reference the existing shared default (e.g. `model.DefaultRefreshInterval`) in the view condition instead of the local constant.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread internal/ui/views.go
Comment on lines +452 to +453
if m.refreshInterval != 100*time.Millisecond {
ifaceStr += theme.Muted().Render(" " + formatInterval(m.refreshInterval))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Avoid hard-coding the 100ms default refresh interval in the view layer

Using 100*time.Millisecond here couples the UI to a specific default. If that default changes, this condition will drift out of sync. Please reference a shared constant (or a model field) instead so changes to the default automatically stay consistent with the display logic.

Suggested implementation:

		if m.refreshInterval != defaultRefreshInterval {
			ifaceStr += theme.Muted().Render("  " + formatInterval(m.refreshInterval))
		}
const defaultRefreshInterval = 100 * time.Millisecond

func formatInterval(d time.Duration) string {

If your project already defines a canonical default refresh interval (e.g. in a config or model package), you should:

  1. Remove the newly added defaultRefreshInterval constant from views.go.
  2. Import and reference the existing shared default (e.g. model.DefaultRefreshInterval) in the view condition instead of the local constant.

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.

Feature request: enrich --once --json snapshot output with timestamp/status/human fields

1 participant