Skip to content

feat(sessions): send the session's artifacts with an import - #686

Merged
ImriKochWix merged 3 commits into
mainfrom
imrik/session-import-artifacts
Nov 1, 2026
Merged

ImriKochWix merged 3 commits into
mainfrom
imrik/session-import-artifacts

Conversation

@ImriKochWix

@ImriKochWix ImriKochWix commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Note

Description

base44 sessions import now uploads the artifacts a session produced alongside the conversation, so the imported branch carries the files the session actually presented. A new core/session-import/artifacts.ts module scans the session log for Claude Code Artifact publishes and Codex open_in_codex file targets, reads only the paths those calls name, and attaches them to the multipart upload with a manifest tying each part back to its tool-use id. The command reports what it sends, why anything was skipped, and the server's saved/not-saved counts.

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

  • New core/session-import/artifacts.ts with collectArtifacts():
    • Finds Claude Code Artifact tool uses (file_path, no action/asset/type_url, non-sidechain) and Codex exec calls that open_in_codex a type: "file" target.
    • Reads only the named paths, and only regular files. A deleted Claude Code file falls back to its last Write that no later Edit/MultiEdit touched; Codex has no fallback.
    • Inlines <img src> values that are keys of a publish's files map as data: URIs, and reports images that are no longer on disk.
    • Limits: one file per path (last call's id), newest 10, 10 MB each, extension allowlist (html/htm/pdf/png/jpg/jpeg/gif/webp/txt/md/csv/json), and drops oldest until session + artifacts + 1 MB margin fit the 95 MB request cap (Cloudflare refuses bodies over 100 MB).
  • core/session-import/api.ts: uploadSession() takes artifacts, appends them as repeated artifacts parts plus an artifact_manifest JSON (tool_use_id, file_name, in order); neither part is sent when there are none. Response schema gains imported_artifacts/skipped_artifacts (defaulting to 0 for older servers), transformed to importedArtifacts/skippedArtifacts.
  • cli/commands/sessions/import.ts: collects artifacts before the upload, logs the list being sent and each skip with its reason, adds an Artifacts: N saved, M not saved. outro line when non-zero, and includes sentArtifacts/unsentArtifacts in --json output.
  • docs/commands.md: new Artifacts bullet documenting discovery, fallbacks, limits, wire format, and output.

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

Tests added: an artifacts suite in tests/cli/sessions_import.spec.ts covering a published HTML file with one inlined and one missing image (including the --json shape), the last-clean-Write fallback versus a file edited afterwards, and Codex open_in_codex dedup keeping the last call's id while ignoring a browser target; plus tests/core/session-import-artifacts.spec.ts for budget-driven dropping of the oldest artifacts. The existing happy-path test now asserts no artifact_manifest part when there are no artifacts. The test suite was not executed in this environment, so the pass boxes are left unchecked.


🤖 Generated by Claude | 2026-11-01 07:22 UTC | 434aab7

An imported session showed the chat but not the deliverable. The import now
finds the files the session presented (Claude Code Artifact publishes, Codex
app open_in_codex of a file), reads only those paths, and sends them as
`artifacts` parts with an `artifact_manifest`, kept under the server's 95 MB
request cap.

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

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.2.6-pr.686.434aab7

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.6-pr.686.434aab7"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.2.6-pr.686.434aab7"
  }
}

Preview published to npm registry — try new features instantly!

ImriKochWix and others added 2 commits October 30, 2026 11:42
Raw Windows paths in the fixture's JS string lost their backslashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They were dropped from the inlined HTML without a word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ImriKochWix
ImriKochWix merged commit 2033e09 into main Nov 1, 2026
15 checks passed
@ImriKochWix
ImriKochWix deleted the imrik/session-import-artifacts branch November 1, 2026 09:21
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