Skip to content

fix: Keep tool rows under their exchange when sorted - #1807

Merged
esnible merged 1 commit into
rossoctl:mainfrom
esnible:fix/tool-row-sort-1805
Nov 11, 2026
Merged

esnible merged 1 commit into
rossoctl:mainfrom
esnible:fix/tool-row-sort-1805

Conversation

@esnible

@esnible esnible commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #1805. Under a sort, the tool rows of agentop's events table left their exchange.

Each tool row had a sort key of its own (#1776, rule 11):

  • On DURATION, TIME and METHOD, the tools ranked among the exchanges by their own values. The issue shows this for DURATION.
  • On every other column (STATUS, TOKENS, COST, HOST, DIR, ACTION, PLUGIN), a tool had the zero value, so all the tools collected at one end of the table: the top for ▲, the bottom for ▼.
  • On TIME▼, the tools of an exchange went above it, because a tool starts after its request.

Change

  • A tool row now has the sort key and the exchange index of its exchange. The last tie-break of sortEventRows (the row position) keeps the tools directly under the exchange, in timeline order.
  • The # cell of a tool row is ┣⚒ or ┗⚒ also under a sort. The ↳<n> cell is gone.
  • A long tool does not move its exchange up a DURATION sort. A later TOTALDURATION column is for that.
  • toolSortKey and toolRow.duration had no other caller, so they are removed.
  • cmd/agentop/README.md says how a sort treats tool rows.

Tests

  • TestToolRows_SortByDuration now checks the case in the issue: a 38s tool stays under its 2s exchange, below a 4.4s exchange.
  • New: TestToolRows_EverySortKeepsToolsUnderTheirExchange sorts on each sortable column in both directions. It checks that each tool row is under its exchange, in timeline order, with the correct # cell. On main it fails in 15 of the 22 cases. The other cases pass on main only because the test data's values tie.
  • Removed: TestToolRows_SortOtherColumnIsStable (the new test covers it), TestToolRows_SortedParentNumberFits (no ↳ cell) and TestToolRow_DurationSortValue (no duration).
  • scripts/dev/go-test-shards.sh -race cmd/agentop: 1017 tests pass. go test -race on the cmd/agentop subpackages passes. go vet ./... and gofmt -l . are clean.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes
    • Sorting events now keeps each exchange’s tool rows directly beneath it, including when sorting by duration. Tool rows remain in timeline order, and index markers stay consistent across sort directions.
  • Documentation
    • Updated the Events-pane guidance to explain how sorting affects exchanges and their tool rows.

Under a sort, each tool row had a sort key of its own (rossoctl#1776, rule
11). So a tool row left its exchange. On DURATION, TIME and METHOD
the tools ranked among the exchanges by their own values. On every
other column a tool had the zero value, so all the tools collected
at one end of the table. On TIME descending, the tools of an
exchange went above it.

Now a tool row has the sort key and the exchange of its exchange.
The row position, the last tie-break, keeps the tools directly under
the exchange in timeline order. The # cell is ┣⚒ or ┗⚒ also under a
sort, so the ↳<n> cell is gone. A long tool does not move its
exchange up a DURATION sort. A later TOTALDURATION column is for
that.

toolSortKey and toolRow.duration had no other caller, so they are
removed. A new test sorts on each sortable column in both
directions and checks that each tool row is under its exchange.

Fixes rossoctl#1805

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
@esnible
esnible requested a review from a team as a code owner November 11, 2026 17:55
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Tool rows now inherit their parent exchange’s sort values and stay beneath it across sortable columns. Their index cells consistently show branch-style markers, and the documentation and tests describe and verify this behavior.

Changes: Events table sorting

Layer / File(s) Summary
Group tool rows during sorting
cmd/agentop/tui/events_pane.go, cmd/agentop/tui/events_columns.go, cmd/agentop/tui/tool_rows.go, cmd/agentop/tui/events_tool_rows_test.go, cmd/agentop/tui/tool_rows_test.go, cmd/agentop/README.md
Tool rows use their parent exchange’s sort key and index, keeping them beneath the exchange. Their index cells always use branch-style markers. Tests cover sortable columns in both directions, and the README describes the behavior.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • rossoctl/cortex issue 1776 — Defines tool-row sorting behavior that keeps each tool beside its exchange, which this change implements.

Possibly related PRs

  • rossoctl/cortex#1778 — Adds tool rows and independent sort keys, which this change replaces with parent exchange sort values.
  • rossoctl/cortex#1715 — Defines exchange sorting and row identity used by this change.
  • rossoctl/cortex#1796 — Changes tool-row navigation in the same events table representation.

Suggested reviewers: huang195, clawgenti

Merge Risk: Minimal · up to 55345

Tool rows now stay under their exchange across sortable columns, which fixes the confusing DURATION sort reported in the linked issue. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: keeping tool rows beneath their parent exchange when sorting.
Linked Issues check Passed Issue #1805 requires tool rows to stay attached to their parent during sorting. In events_pane.go, each tool row receives its exchange's sort key and exchange index. The row-position tie-break then …
Out of Scope Changes check Passed The changes stay within issue #1805. They update event sorting, tool-row markers, related documentation, and focused tests. Removing unused toolSortKey and toolRow.duration supports the sorting ch…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #1805 requires tool rows to stay attached to their parent during sorting. In events_pane.go, each tool row receives its exchange's sort key and exchange index. The row-position tie-break then keeps the tool rows directly below the exchange in timeline order. events_columns.go keeps the ┣⚒ and ┗⚒ markers under sorting. TestToolRows_SortByDuration covers the reported duration case, and TestToolRows_EverySortKeepsToolsUnderTheirExchange covers all sortable columns in both directions.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #1805. They update event sorting, tool-row markers, related documentation, and focused tests. Removing unused toolSortKey and toolRow.duration supports the sorting change. No unrelated behavior is demonstrated.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9f1f3441-3155-474b-9480-a4b48ffa3e6a
Commits

Reviewing files that changed from the base of the PR and between a6fbd45 and 553450f.

Files selected for processing: 6

  • cmd/agentop/README.md
  • cmd/agentop/tui/events_columns.go
  • cmd/agentop/tui/events_pane.go
  • cmd/agentop/tui/events_tool_rows_test.go
  • cmd/agentop/tui/tool_rows.go
  • cmd/agentop/tui/tool_rows_test.go
Files with no reviewable changes: 2

  • cmd/agentop/tui/tool_rows.go
  • cmd/agentop/tui/tool_rows_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

The fix is correct and small. Each tool row now gets its exchange's rowKey (same sort value, same arrival index), so all three tiers of sortEventRows tie for an exchange and its tools. The stable row-position tie-break then keeps the tools directly under the exchange, in timeline order, whichever way the sort runs. Removing toolSortKey, toolRow.duration and the sorted parameter leaves no dangling callers. No ↳ remains in non-test code; the only mention left is in tool_enter_test.go's negative assertion, which still holds.

Verified at 553450f:

  • I rendered the real eventsTbl.View() with 3 exchanges and 4 tools (two under exchange 1, one still running) on chronological, DURATION▼, TIME▼ and COST▲. In every view each tool sits directly under its exchange, with ┣⚒/┗⚒ in the # column. The 16s tool under the 4s exchange and the 57s running tool under the 1s exchange no longer move up a DURATION▼ sort. TIME▼ no longer puts tools above their exchange.
  • I ran the new TestToolRows_EverySortKeepsToolsUnderTheirExchange and the updated TestToolRows_SortByDuration against base a6fbd45: both fail, on placement for ACTION/DIR/DURATION/TIME/... and on the ↳<n> cell for every column. At head they pass, so the tests catch the bug.
  • go test -race ./cmd/agentop/tui/ passes, and go vet and gofmt -l are clean.

Author: esnible (MEMBER — maintainer)
Areas reviewed: Go (agentop TUI sort/render), tests, Docs (README)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (Go CI (core peerproc, macOS) still pending; it does not touch cmd/agentop)

}
case tr.last:
// Also under a sort: the tool rows stay under their exchange (#1805).
if v = "┣⚒"; tr.last {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: setting the default in the if init statement (if v = "┣⚒"; tr.last {) is legal but unusual, and at a glance it reads like a comparison. Maybe write it plainly:

v = "┣⚒"
if tr.last {
	v = "┗⚒"
}

@esnible
esnible merged commit 700e0f3 into rossoctl:main Nov 11, 2026
39 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 11, 2026
@esnible
esnible deleted the fix/tool-row-sort-1805 branch November 11, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Tool calls disconnect from their parent when sorted

2 participants