Refactor trace server sort to SortMode enum (execution order / value / name)#92873
Merged
Refactor trace server sort to SortMode enum (execution order / value / name)#92873
Conversation
Replace `sorted: bool` / `sort: bool` with a `SortMode` enum across the entire trace server stack (viewer, server, lib, napi bindings, MCP tool, CLI, and tests). The enum supports three modes: - `ExecutionOrder` — no sorting (previous `false`) - `Value` — sort by corrected duration descending (previous `true`) - `Name` — sort alphabetically by nice_name() title, then category WebSocket protocol maintains backward compatibility: the old `-sorted` suffix maps to `SortMode::Value`, while new suffixes `-sorted-by-value` and `-sorted-by-name` are also supported. Co-Authored-By: Claude <noreply@anthropic.com>
Collaborator
Tests Passed |
Collaborator
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
Merging this PR will not alter performance
Comparing Footnotes
|
mischnic
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Replaces the boolean
sortflag in the trace server with aSortModeenum supporting three modes:ExecutionOrder— no sorting, spans appear in natural/execution order (previousfalse)Value— sort by corrected duration descending (previoustrue)Name— sort alphabetically by span name (title), then by categoryWhy?
The boolean
sortonly allowed toggling duration-based sorting on/off. Adding alphabetical sorting by name makes it easier to find duplicate spans and locate a specific span by name in the trace viewer. The enum is extensible for future sort modes without breaking changes.How?
Rust (
turbopack-trace-server):SortMode { ExecutionOrder, Value, Name }enum to bothlib.rs(for the query API) andviewer.rs(for the WebSocket viewer).ViewModevariants changed fromsorted: booltosort_mode: SortMode.sort_children()now returnsSortModeinstead ofbool; all 10 sorting branches inviewer.rsconverted fromif/elseto a 3-armmatch.Namesort usesnice_name()— sorts by title first, then category, both ascending.SpanEventRef::SelfTimeandSpanGraphEventRef::SelfTime(which have no name) sort as("", "")underNamemode.WebSocket protocol (backward compatible):
-sortedsuffix →SortMode::Value(existing clients unaffected)-sorted-by-valuesuffix →SortMode::Value-sorted-by-namesuffix →SortMode::NameSortMode::ExecutionOrdernapi bindings (
next-napi-bindings):TraceQueryOptions.sortchanged fromOption<bool>toOption<String>("value"|"name"| omit).TypeScript:
generated-native.d.ts:sort?: 'value' | 'name'z.enum(['value', 'name']).optional()--sort <mode>with.choices(['value', 'name'])replacing the boolean--sortflagsort: 'name'and--sort name