Skip to content

feat(sessions): send pasted and attached images, drop tool screenshots - #683

Merged
ImriKochWix merged 1 commit into
mainfrom
imrik/session-import-images
Oct 29, 2026
Merged

ImriKochWix merged 1 commit into
mainfrom
imrik/session-import-images

Conversation

@ImriKochWix

@ImriKochWix ImriKochWix commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Note

Description

base44 sessions import now sends the images a person actually put into a session and strips the ones the agent's own tools produced. Screenshots and Reads of PNGs are dropped before upload — Base Code never imports them and they account for most of a large session's size — while an image attached as a file path (the way wrappers around Claude Code and Codex pass them) is inlined into the user's message as if it had been pasted, but only once a tool actually opened that path. The pre-upload size ceiling moves from 25 MB to 50 MB now that tool-produced image data no longer inflates the payload.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Added `packages/cli/src/core/session-import/images.ts` with `prepareSessionImages()`, which rewrites a session's JSONL line-by-line and only re-serializes the lines it changed.
  • Strip tool-produced images: `image`/`input_image` blocks are removed from Claude Code `tool_result` blocks (along with the duplicated `toolUseResult` field) and from Codex `*_output` payload items.
  • Inline attached images: file paths mentioned in a typed user message are read from disk and appended as an `image` block (Claude Code) or `input_image` data URL (Codex), but only when the path also appears in some tool call's input — a path that was merely mentioned is ignored.
  • Guardrails on inlining: newest 20 images only (walking entries newest-first), 10 MB per image, and `.png`/`.jpg`/`.jpeg`/`.gif`/`.webp` media types only; unreadable paths, non-files, and oversize files are skipped silently.
  • Meta and sidechain user entries, and messages whose content is a `tool_result`, are not treated as typed user messages, so agent-side paths don't trigger an upload.
  • Wired `prepareSessionImages()` into the `sessions import` command between reading the session and the size check.
  • Raised `MAX_SESSION_BYTES` to 50 MB and updated both the local pre-flight error and the HTTP 413 message to match.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (`npm test`)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated `docs/` (AGENTS.md) if I made architectural changes

Additional Notes

Two integration tests cover the new behaviour in `packages/cli/tests/cli/sessions_import.spec.ts`: one asserts a pasted image survives upload while a `Read`-produced image is gone (and the `tool_result` block itself is kept), the other asserts a Codex rollout inlines the attached PNG that `view_image` opened and leaves the merely-listed one out. The existing size-limit test was updated to the new 50 MB threshold. The test suite was not executed in this environment.


🤖 Generated by Claude | 2026-10-29 09:59 UTC | ac5c3c2

Base Code now imports the images a user pasted (base44-dev/apper#35805).
Before uploading, sessions import drops images the agent's tools produced
(they are most of a big session's size and the server never imports them)
and adds an image the user attached as a file path, as apps that wrap Claude
Code or Codex do, once the agent opened it. The size limit goes from 25 to
50 MB to match the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.2.5-pr.683.39ac9ac

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.2.5-pr.683.39ac9ac"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.2.5-pr.683.39ac9ac"
  }
}

Preview published to npm registry — try new features instantly!

@ImriKochWix
ImriKochWix merged commit c9cdd64 into main Oct 29, 2026
15 checks passed
@ImriKochWix
ImriKochWix deleted the imrik/session-import-images branch October 29, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants