fix(cli): sort sandbox list by timestamp instead of locale date string#1573
fix(cli): sort sandbox list by timestamp instead of locale date string#1573mishushakov wants to merge 1 commit into
Conversation
Sorting happened after startedAt was converted with toLocaleString(), so rows were ordered lexicographically by the formatted string (e.g. "9/1/2026" > "10/1/2026" in en-US), breaking chronological order across single-digit/double-digit month and day boundaries. Sort by the raw timestamp before formatting instead. Fixes #1572 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 7795f4d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR SummaryLow Risk Overview Reviewed by Cursor Bugbot for commit 7795f4d. Bugbot is set up for automated code reviews on this repo. Configure here. |
Package ArtifactsBuilt from 7fc7cb3. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.35.1-fix-issue-1572.0.tgzCLI ( npm install ./e2b-cli-2.13.4-fix-issue-1572.0.tgzPython SDK ( pip install ./e2b-2.34.0+fix.issue.1572-py3-none-any.whl |
There was a problem hiding this comment.
LGTM — straightforward fix that sorts by raw timestamp instead of locale-formatted string, with solid test coverage for the regression case.
Extended reasoning...
Overview
The PR touches a single CLI command (sandbox list) in packages/cli/src/commands/sandbox/list.ts. It extracts the row-building/sorting logic into an exported buildTableRows helper and fixes a real bug: rows were previously sorted using localeCompare on already-formatted date strings (e.g. toLocaleString() output), which breaks chronological order whenever single-digit and double-digit months/days are compared lexicographically (September vs October). The fix sorts on the raw startedAt timestamp (via new Date(...).getTime()) before formatting for display, preserving the existing sandbox-ID tiebreak. It also switches from mutating the input array in place to using .slice() first.
Security risks
None. This is a purely local, display-only sorting change in the CLI's table-rendering code path. No auth, network, or data-handling logic is touched.
Level of scrutiny
Low. This is a small, self-contained bug fix in a non-critical CLI display path, following an established pattern (extract a pure helper function) with no ambiguity in intent or implementation.
Other factors
The fix is verified by new unit tests that directly cover the regression scenario (September sorted before October), tie-breaking by sandbox ID on identical timestamps, date/state formatting, and non-mutation of the input array. The diff is minimal and mechanical — logic was moved almost verbatim, with just the sort key changed from formatted string to raw timestamp. No outstanding review comments to address.
Fixes #1572
Problem
e2b sandbox listsorted rows after convertingstartedAtto a locale string, so ordering was lexicographic over strings like"9/1/2026, 10:00:00 AM". In en-US,"9/..."sorts after"10/...", so September sandboxes appeared after October ones — chronological order broke at any single-digit/double-digit month or day boundary.Fix
Sort by the raw
startedAttimestamp (with the existing sandbox-ID tiebreak) before formatting for display. The row-building logic is extracted into an exportedbuildTableRowshelper and covered by unit tests, including the September/October regression case. The input array is no longer mutated in place.Example
🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.