Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(cli): sort sandbox list by timestamp instead of locale date string#1573

Open
mishushakov wants to merge 1 commit into
maine2b-dev/E2B:mainfrom
fix-issue-1572e2b-dev/E2B:fix-issue-1572Copy head branch name to clipboard
Open

fix(cli): sort sandbox list by timestamp instead of locale date string#1573
mishushakov wants to merge 1 commit into
maine2b-dev/E2B:mainfrom
fix-issue-1572e2b-dev/E2B:fix-issue-1572Copy head branch name to clipboard

Conversation

@mishushakov

@mishushakov mishushakov commented Jul 21, 2026

Copy link
Copy Markdown
Member

Fixes #1572

Problem

e2b sandbox list sorted rows after converting startedAt to 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 startedAt timestamp (with the existing sandbox-ID tiebreak) before formatting for display. The row-building logic is extracted into an exported buildTableRows helper and covered by unit tests, including the September/October regression case. The input array is no longer mutated in place.

Example

$ e2b sandbox list --state paused

Paused sandboxes
Sandbox ID   ...  Started at
sbx-sep      ...  9/1/2026, 12:00:00 PM    ← previously listed after October
sbx-oct      ...  10/1/2026, 11:00:00 AM

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

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-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7795f4d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@e2b/cli Patch

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

@cursor

cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CLI display-only sorting change with tests; no auth, API, or data handling impact.

Overview
e2b sandbox list sorted rows using locale-formatted startedAt strings, so order was lexicographic and wrong when months or days crossed single- vs double-digit boundaries (for example September after October in en-US). Sorting now uses the raw startedAt timestamp with the same sandbox ID tiebreak, then formats for display. Row building lives in exported buildTableRows, with unit tests and a non-mutating slice() before sort.

Reviewed by Cursor Bugbot for commit 7795f4d. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

Package Artifacts

Built from 7fc7cb3. Download artifacts from this workflow run.

JS SDK (e2b@2.35.1-fix-issue-1572.0):

npm install ./e2b-2.35.1-fix-issue-1572.0.tgz

CLI (@e2b/cli@2.13.4-fix-issue-1572.0):

npm install ./e2b-cli-2.13.4-fix-issue-1572.0.tgz

Python SDK (e2b==2.34.0+fix.issue.1572):

pip install ./e2b-2.34.0+fix.issue.1572-py3-none-any.whl

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: sandbox list sorts by locale-formatted date string, breaking chronological order

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.