Skip to content

Update dependencies and add MTR probe history feature#368

Merged
tsosunchia merged 12 commits into
mainfrom
main
May 20, 2026
Merged

Update dependencies and add MTR probe history feature#368
tsosunchia merged 12 commits into
mainfrom
main

Conversation

@tsosunchia
Copy link
Copy Markdown
Member

@tsosunchia tsosunchia commented May 20, 2026

Summary by CodeRabbit

  • New Features

    • 增加 MTR 历史视图与三种图表模式(heatmap/bars/sparkline);支持 d/D 切换历史模式、g/G 切换图表模式,并在 TUI 展示历史数据。
  • Documentation

    • 补充 macOS Homebrew 安装与 Full/Tiny/NTR 三种 flavor 的兼容性与示例;更新 MTR TUI 快捷键与历史显示说明。
  • Tests

    • 大量新增 MTR 历史、渲染与交互相关测试覆盖。
  • Chores

    • 调整/重构 CI 发布流程(移除旧的自动发布步骤并更新发布工作流);更新若干依赖版本。

Review Change Stack

dependabot Bot and others added 8 commits May 4, 2026 18:54
Bumps [github.com/modelcontextprotocol/go-sdk](https://github.com/modelcontextprotocol/go-sdk) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/modelcontextprotocol/go-sdk/releases)
- [Commits](modelcontextprotocol/go-sdk@v1.5.0...v1.6.0)

---
updated-dependencies:
- dependency-name: github.com/modelcontextprotocol/go-sdk
  dependency-version: 1.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…/modelcontextprotocol/go-sdk-1.6.0

chore(deps): bump github.com/modelcontextprotocol/go-sdk from 1.5.0 to 1.6.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.53.0 to 0.54.0.
- [Commits](golang/net@v0.53.0...v0.54.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.54.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…/x/net-0.54.0

chore(deps): bump golang.org/x/net from 0.53.0 to 0.54.0
Bumps [github.com/tidwall/gjson](https://github.com/tidwall/gjson) from 1.18.0 to 1.19.0.
- [Commits](tidwall/gjson@v1.18.0...v1.19.0)

---
updated-dependencies:
- dependency-name: github.com/tidwall/gjson
  dependency-version: 1.19.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…/tidwall/gjson-1.19.0

chore(deps): bump github.com/tidwall/gjson from 1.18.0 to 1.19.0
- 新增 MTR probe history store 与 TUI history/chart 模式
- 增加 d/g 快捷键、OnProbe 事件和相关测试
- 更新中英文 README 并致谢 TraceBar
Copilot AI review requested due to automatic review settings May 20, 2026 13:59
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f071233-fd31-474a-911f-19c67d105c0e

📥 Commits

Reviewing files that changed from the base of the PR and between ef3cca4 and 60a9199.

📒 Files selected for processing (1)
  • printer/mtr_tui.go

Walkthrough

此变更扩展了 MTR 探测链路以向外发出带完成时间的事件,新增按 TTL 分组的历史存储与快照接口,添加 d/D 与 g/G 快捷键并在 TUI 中实现 heatmap/bars/sparkline 三种历史视图;同时重构 Homebrew 发布工作流、更新 README 并升级若干 Go 依赖。

Changes

MTR 历史显示功能实现

Layer / File(s) Summary
探测事件回调基础设施
trace/mtr_runner.go, trace/mtr_scheduler.go, trace/mtr_scheduler_runtime.go, trace/mtr_raw.go
MTROptions 新增 OnProbe 回调与 MTRProbeEventrunMTRScheduler 回调签名扩展为传递探测完成时间戳;runtime 将 doneAt 贯穿到事件生成与 onProbe 触发。
历史采样存储与窗口管理
printer/mtr_history.go, printer/mtr_table_test.go
实现 MTRHistoryStore:按 TTL 分组样本、AddProbeEvent 接收事件并基于窗口修剪、Reset 清空、Snapshot 返回不可变快照;增加多项存储测试。
UI 历史模式与快捷键处理
cmd/mtr_ui.go, cmd/mtr_mode_test.go
mtrUI 新增 atomic 状态 historyMode/chartMode 与公开控制方法;按键解析与分发支持 d/D(history toggle)与 g/G(chart cycle);新增相关单元测试。
TUI 颜色与历史视图渲染
printer/mtr_tui_color.go, printer/mtr_tui.go, printer/mtr_table_test.go
新增历史渲染颜色/样式支持,扩展 MTRTUIHeaderMTRTUIPrinter 接收 history 回调并在 history 模式下渲染专用历史视图,支持 heatmap/bars/sparkline 三种图表;新增渲染测试覆盖多场景。
历史功能集成与运行时
cmd/mtr_mode.go
runMTRTUI 在 TTY 条件下通过 attachMTRHistoryIfTTY 创建历史存储并将 AddProbeEvent 绑定到 opts.OnProbe,包装重置请求并把 history.Snapshot 注入渲染闭包。
调度器事件语义测试
trace/mtr_scheduler_test.go
更新多项测试以适配新回调签名;新增事件语义测试验证事件计数与聚合器 Snt 一致、Timestamp 语义与合成超时 doneAt 准确性。

工作流优化与文档更新

Layer / File(s) Summary
GitHub Actions 工作流重构
.github/workflows/build.yml, .github/workflows/publishNewFormula.yml
从 build.yml 移除旧的 publish-new-formula 步骤;新增/重写 publishNewFormula.yml:显式 permissions 和 bash shell、把克隆与生成步骤分离、仅在有变更时通过 git diff --cached --quiet 提交并用 GT_TOKEN 推送。
安装与快捷键文档更新
README.md, README_zh_CN.md
补充 nxtrace/nexttrace tap 的安装示例与 Full/Tiny/NTR 三种 flavor 的支持说明,扩展 MTR TUI 快捷键与历史渲染细节的文档。
Go 依赖版本更新
go.mod
升级若干依赖版本(如 modelcontextprotocol/go-sdk、tidwall/gjson、golang.org/x/* 等)。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

兔子在终端轻声跳,
TTL 时序排成条,
d 键召回历史笑,g 键切图表,
小兔挥爪看数据,夜色也温柔笑。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.05% 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 PR标题准确总结了主要变更:更新依赖和添加MTR探测历史功能,与文件变更内容(go.mod更新和多个MTR历史相关文件)相符。
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@README_zh_CN.md`:
- Line 110: Update the inaccurate statement "homebrew-core 版仅支持 amd64" in
README_zh_CN.md: replace it with wording that homebrew-core supports multiple
architectures (e.g. macOS arm64 & x86_64 and Linux arm64 & x86_64) or simply
remove the explicit architecture restriction; keep the rest of the sentence
about "`nxtrace/nexttrace` tap 提供三种 flavor" intact to preserve contrast between
homebrew-core and the tap.

In `@README.md`:
- Around line 112-113: The README claim "homebrew-core version only supports
amd64" is inaccurate; update the text to correctly state that the homebrew-core
formula provides the Full flavor (`nexttrace`) while the `nxtrace/nexttrace` tap
provides all three flavors — replace the incorrect sentence with: "The
homebrew-core formula provides the Full flavor (`nexttrace`); the
`nxtrace/nexttrace` tap provides all three flavors." Refer to the existing
sentence containing "homebrew-core version only supports amd64" to locate and
replace it.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47a0324a-cc78-46e9-807d-bc8d0fa32c37

📥 Commits

Reviewing files that changed from the base of the PR and between 21fdd74 and 9fc8c49.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (17)
  • .github/workflows/build.yml
  • .github/workflows/publishNewFormula.yml
  • README.md
  • README_zh_CN.md
  • cmd/mtr_mode.go
  • cmd/mtr_mode_test.go
  • cmd/mtr_ui.go
  • go.mod
  • printer/mtr_history.go
  • printer/mtr_table_test.go
  • printer/mtr_tui.go
  • printer/mtr_tui_color.go
  • trace/mtr_raw.go
  • trace/mtr_runner.go
  • trace/mtr_scheduler.go
  • trace/mtr_scheduler_runtime.go
  • trace/mtr_scheduler_test.go
💤 Files with no reviewable changes (1)
  • .github/workflows/build.yml

Comment thread README_zh_CN.md Outdated
Comment thread README.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an optional MTR TUI “history” view backed by per-probe timestamps, and updates several Go dependencies plus the Homebrew formula publishing workflow.

Changes:

  • Add per-probe callback plumbing (MTROptions.OnProbe) emitting timestamped MTRProbeEvents from the per-hop scheduler.
  • Add a rolling 3-minute probe history store and new TUI rendering path (history table + heatmap/bars/sparkline modes) with new key bindings (d/g).
  • Update Go module dependencies and split/schedule the Homebrew formula publishing workflow.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
trace/mtr_scheduler.go Extends onProbe callback signature with completion timestamp and adds result→event adapter.
trace/mtr_scheduler_runtime.go Threads probe completion time through success/error paths and synthetic timeouts to the onProbe callback.
trace/mtr_runner.go Adds MTROptions.OnProbe + MTRProbeEvent and wires options into per-hop scheduler.
trace/mtr_raw.go Updates raw per-hop scheduler callback signature to accept the new timestamp argument.
trace/mtr_scheduler_test.go Updates existing scheduler tests for new callback signature and adds timestamp/event-count tests.
printer/mtr_history.go Introduces rolling, per-TTL history store with windowing and snapshotting.
printer/mtr_tui.go Adds history-mode header fields, key hints, and history rendering (layout + charting).
printer/mtr_tui_color.go Adds history-specific color helpers and latency/timeout styling.
printer/mtr_table_test.go Adds unit tests for history store and history-mode rendering behaviors.
cmd/mtr_ui.go Adds history-mode and chart-mode state + key bindings (d/g).
cmd/mtr_mode.go Instantiates the history store, wires OnProbe, and passes history snapshot into the TUI printer.
cmd/mtr_mode_test.go Adds tests for new key parsing and history mode/chart cycling logic.
README.md Updates packaging notes and documents new MTR history display and key bindings.
README_zh_CN.md Chinese README updates matching packaging notes and history display docs.
go.mod Bumps several dependencies (MCP SDK, gjson, x/net, x/sys, x/term, etc.).
go.sum Updates checksums corresponding to dependency bumps and new transitive deps.
.github/workflows/publishNewFormula.yml Modernizes workflow, adds weekly schedule, and only commits/pushes when formula changes.
.github/workflows/build.yml Removes the formula publishing job from the main build workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/mtr_mode.go Outdated
Comment on lines 89 to 104
history := printer.NewMTRHistoryStore(printer.MTRHistoryWindow)
opts.OnProbe = history.AddProbeEvent
if opts.IsResetRequested != nil {
resetRequested := opts.IsResetRequested
opts.IsResetRequested = func() bool {
if !resetRequested() {
return false
}
history.Reset()
return true
}
}

// TTY 模式下使用 TUI 渲染器 + 暂停支持,非 TTY 使用简单表格
var onSnapshot trace.MTROnSnapshot
if ui.IsTTY() {
Comment thread printer/mtr_history.go
Comment on lines +52 to +65
at := event.Timestamp
if at.IsZero() {
at = time.Now()
}
sample := MTRHistorySample{
At: at,
RTT: event.RTT,
Timeout: !event.Success,
}
s.mu.Lock()
defer s.mu.Unlock()
s.byTTL[event.TTL] = append(s.byTTL[event.TTL], sample)
s.pruneLocked(at)
}
Comment thread printer/mtr_history.go
Comment on lines +103 to +117
func (s *MTRHistoryStore) pruneLocked(now time.Time) {
cutoff := now.Add(-s.window)
for ttl, samples := range s.byTTL {
kept := samples[:0]
for _, sample := range samples {
if !sample.At.Before(cutoff) {
kept = append(kept, sample)
}
}
if len(kept) == 0 {
delete(s.byTTL, ttl)
continue
}
s.byTTL[ttl] = kept
}
Comment thread printer/mtr_tui_color.go
Comment on lines +58 to +61
func mtrTUIHistoryLatencyColor(s string, level int) string {
sty := color.New(mtrHistoryLatencyColorAttr(level)).SprintFunc()
return sty(s)
}
Comment thread trace/mtr_scheduler.go
Comment on lines 80 to 89
// onSnapshot is called periodically with aggregated stats (for TUI / report).
// onProbe is called per completed probe (for raw streaming mode).
func runMTRScheduler(
ctx context.Context,
prober mtrTTLProber,
agg *MTRAggregator,
cfg mtrSchedulerConfig,
onSnapshot MTROnSnapshot,
onProbe func(result mtrProbeResult, iteration int),
onProbe func(result mtrProbeResult, iteration int, at time.Time),
) error {
@tsosunchia
Copy link
Copy Markdown
Member Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b5ca7b409

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread printer/mtr_tui.go Outdated
Comment on lines +1083 to +1084
if historySnapshot != nil {
history = historySnapshot(now)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid snapshotting history when classic view is active

MTRTUIPrinter calls historySnapshot(now) on every render tick even when HistoryMode is false, and MTRHistoryStore.Snapshot deep-copies all TTL sample slices. In long-running/default classic TUI sessions (especially with small --ttl-time), this adds avoidable O(total history samples) allocations and copy work every frame, which can noticeably increase CPU and GC pressure without affecting output. Only snapshotting when history view is enabled (or otherwise needed) prevents this regression.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Comment thread printer/mtr_history.go Outdated
Comment on lines +52 to +60
now := time.Now()
at := event.Timestamp
if at.IsZero() {
at = now
}
pruneAt := now
if at.After(pruneAt) {
pruneAt = at
}
Comment thread printer/mtr_tui.go
Comment on lines +1081 to +1085
now := time.Now()
var history []MTRHistoryTTL
if historySnapshot != nil {
history = historySnapshot(now)
}
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.

Comment thread printer/mtr_tui.go Outdated
Comment on lines +924 to +937
s := samples[i]
if s.At.Before(windowStart) || s.At.After(now) {
continue
}
pos := int(s.At.Sub(windowStart) * time.Duration(width) / MTRHistoryWindow)
if pos < 0 {
pos = 0
}
if pos >= width {
pos = width - 1
}
cp := s
if bins[pos] == nil || bins[pos].At.Before(s.At) {
bins[pos] = &cp
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated no new comments.

@tsosunchia tsosunchia merged commit a0a8fa9 into nxtrace:main May 20, 2026
45 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.

2 participants