Skip to content

fix(code-interpreter): list text and chart in JS Result.formats() - #1982

Open
lemonzoey wants to merge 1 commit into
e2b-dev:mainfrom
lemonzoey:zhouyi/fix-formats-chart-text
Open

lemonzoey wants to merge 1 commit into
e2b-dev:mainfrom
lemonzoey:zhouyi/fix-formats-chart-text

Conversation

@lemonzoey

@lemonzoey lemonzoey commented Oct 14, 2026 •

Copy link
Copy Markdown

Summary

Result.formats() in the JS Code Interpreter SDK reported every available representation except text and chart, so a result carrying either reported no formats at all (a text+chart result returned []). This diverged from the Python SDK, whose Result.formats() lists both. Fixes #1981.

The JS formats() listed html, markdown, svg, png, jpeg, pdf, latex, json, javascript, data, and extra keys — but not text or chart. This adds text (first) and chart (after data), matching the Python SDK's ordering:

   formats(): string[] {
     const formats = []
+    if (this.text) {
+      formats.push('text')
+    }
     if (this.html) { formats.push('html') }
     ...
     if (this.data) {
       formats.push('data')
     }
+    if (this.chart) {
+      formats.push('chart')
+    }

Usage example

const execution = await sandbox.runCode('print("hello")')
const result = execution.results[0]

// Before: [] — the result has a text representation but formats() reported none
// After:
result.formats() // ['text']
const execution = await sandbox.runCode(`
  import matplotlib.pyplot as plt
  plt.bar(['a', 'b'], [1, 2])
  plt.show()
`)
const result = execution.results[0]

// Before: []  (chart present but invisible to formats())
// After:
result.formats() // ['text', 'chart']

Discovery via formats() now works as expected:

if (result.formats().includes('chart')) {
  renderChart(result.chart)
}

Testing

formats() had no JS test coverage. Adds packages/code-interpreter-js/tests/formats.test.ts covering: a text-only result, a chart result, a text+chart result (asserting the Python order), a result with every format (asserting the full Python ordering), and a bare result (empty). All no-credential unit tests pass; format / lint / typecheck clean (the one remaining messaging.ts lint warning is pre-existing and unrelated).

Scope

JS-only — Python already does the right thing. This is separate from the ongoing Result serialization work and does not overlap:

It complements #1948: that makes chart survive toJSON() serialization; this makes chart discoverable via formats().

🤖 Generated with kscc


Devin Review

@cla-bot

cla-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: zhouyi7.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@changeset-bot

changeset-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84f1220

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

This PR includes changesets to release 1 package
Name Type
@e2b/code-interpreter 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T09:44:15.804647Z 02722b3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TASTE.md review: compliant — checked T-1 (JS/Python parity; the new text/chart entries and their order now match Python Result.formats() exactly), T-15, T-19, T-69/T-72; 0 violations in the changed lines.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

`Result.formats()` reported every available representation except `text`
and `chart`, so a result carrying either reported no formats at all — a
text+chart result returned `[]`. Append `text` and `chart` in the same
positions the Python SDK's `Result.formats()` uses, so JS now matches
Python's ordering (text, the MIME types, data, chart, then extra keys).

Co-Authored-By: Kscc <noreply@owtffssent.com>
@lemonzoey
lemonzoey force-pushed the zhouyi/fix-formats-chart-text branch from 02722b3 to 84f1220 Compare October 15, 2026 02:21
@cla-bot

cla-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @lemonzoey on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@lemonzoey

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Oct 15, 2026
@cla-bot

cla-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

This branch has not been deployed

No deployments
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.

[Bug]: JS Code Interpreter Result.formats() omits text and chart

1 participant