Update dependencies and add MTR probe history feature#368
Conversation
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
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough此变更扩展了 MTR 探测链路以向外发出带完成时间的事件,新增按 TTL 分组的历史存储与快照接口,添加 d/D 与 g/G 快捷键并在 TUI 中实现 heatmap/bars/sparkline 三种历史视图;同时重构 Homebrew 发布工作流、更新 README 并升级若干 Go 依赖。 ChangesMTR 历史显示功能实现
工作流优化与文档更新
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (17)
.github/workflows/build.yml.github/workflows/publishNewFormula.ymlREADME.mdREADME_zh_CN.mdcmd/mtr_mode.gocmd/mtr_mode_test.gocmd/mtr_ui.gogo.modprinter/mtr_history.goprinter/mtr_table_test.goprinter/mtr_tui.goprinter/mtr_tui_color.gotrace/mtr_raw.gotrace/mtr_runner.gotrace/mtr_scheduler.gotrace/mtr_scheduler_runtime.gotrace/mtr_scheduler_test.go
💤 Files with no reviewable changes (1)
- .github/workflows/build.yml
There was a problem hiding this comment.
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 timestampedMTRProbeEvents 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.
| 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() { |
| 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) | ||
| } |
| 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 | ||
| } |
| func mtrTUIHistoryLatencyColor(s string, level int) string { | ||
| sty := color.New(mtrHistoryLatencyColorAttr(level)).SprintFunc() | ||
| return sty(s) | ||
| } |
| // 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 { |
|
@codex review |
There was a problem hiding this comment.
💡 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".
| if historySnapshot != nil { | ||
| history = historySnapshot(now) |
There was a problem hiding this comment.
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 👍 / 👎.
| now := time.Now() | ||
| at := event.Timestamp | ||
| if at.IsZero() { | ||
| at = now | ||
| } | ||
| pruneAt := now | ||
| if at.After(pruneAt) { | ||
| pruneAt = at | ||
| } |
| now := time.Now() | ||
| var history []MTRHistoryTTL | ||
| if historySnapshot != nil { | ||
| history = historySnapshot(now) | ||
| } |
| 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 |
Summary by CodeRabbit
New Features
Documentation
Tests
Chores