feat(ui): sort session sidebar calls by duration or start time - #32432
Conversation
Greptile SummaryThis PR adds a sort-mode toggle to the session sidebar in
Confidence Score: 5/5Safe to merge — the change is self-contained UI logic with no backend or data-model impact and is well covered by both unit and component tests. The sort helper is a pure, non-mutating function with full unit test coverage. The state management in the drawer is straightforward: the query result is unchanged, ordering is applied in a No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx | Moves session ordering from the query into a useMemo driven by sessionSortMode; adds a Segmented toggle rendered only in session mode; resets sort mode to "duration" when the drawer closes |
| ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/utils.ts | Adds SessionLogSortMode type and sortSessionLogs helper; correctly spreads input to avoid mutation and falls back to timestamp difference when request_duration_ms is absent |
| ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.test.tsx | Component-level tests verify default duration ordering, toggle to chronological, toggle back, and that sort mode resets to duration after the drawer closes and reopens |
| ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/utils.test.ts | Unit tests for sortSessionLogs cover both modes, the timestamp-based duration fallback, and non-mutation of the input array |
Reviews (2): Last reviewed commit: "fix(ui): reset session sort mode when dr..." | Re-trigger Greptile
Merging this PR will improve performance by 20.47%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_completion_simple_message |
4.6 ms | 3.9 ms | +20.47% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing thibault-linktree:litellm_ui_session_sidebar_sort_toggle (6d2090a) with litellm_internal_staging (cd6e8cd)1
Footnotes
|
Addressed the review feedback: the sort mode now resets to the duration default when the drawer closes, with a regression test that closes and reopens the drawer after switching modes. Also note the toggle was reworked since the first review; the grouped ordering is gone and the two modes are now Duration (default) and Start time |
Relevant issues
Fixes #32431
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Before/after screenshots to be added in a comment (before at the merge base, after at 6d2090a). Steps to reproduce: run the proxy and the dashboard dev server, open http://localhost:3000/ui/?page=logs, click the session id of a session that mixes LLM and MCP calls, and look at the left sidebar of the drawer. Before this change the sidebar always lists LLM calls first and MCP calls last, newest first within each group, with no way to change it. After this change a Duration / Start time toggle sits under the session stats; Duration sorts the whole list by request duration, longest first, and Start time re-sorts it chronologically, interleaving LLM and MCP calls in the order they actually ran
Type
🆕 New Feature
Changes
The session drawer sidebar (LogDetailsDrawer) previously hardcoded its ordering inside the react-query fetch: MCP calls grouped after LLM calls, newest first within each group. That ordering is hard to reason about when debugging a session that interleaves LLM turns with MCP tool calls; you can neither see the slowest calls at a glance nor follow the actual execution order
This PR moves the ordering out of the query into a pure
sortSessionLogs(rows, mode)helper inLogDetailsDrawer/utils.tsand adds a compact antd Segmented toggle to the sidebar header with two modes.durationis the default and sorts every call by request duration descending (falling back to endTime minus startTime whenrequest_duration_msis absent);start_timesorts every call by start time ascending so the list reads top to bottom in execution order. Both modes interleave LLM, agent and MCP calls; the previous group-by-type ordering is intentionally dropped since it obscured both dimensions. The toggle only renders in session mode, and the selected mode resets to duration when the drawer closes so it does not leak into the next session a user opensTests: unit tests for
sortSessionLogspin both orderings, the timestamp fallback for missing durations and non-mutation of the input, and a component test renders the drawer in session mode, asserts the default duration order, clicks Start time and asserts the interleaved chronological order, then toggles backTest
Before
Tools are sorted by default by duration and don't show call order
After
You can sort by duration (default) or by start time (new)