Skip to content

fix(copilot): make stored MIME the source of truth for workspace file writes - #6470

Open
j15z wants to merge 1 commit into
stagingfrom
fix/ship-file-gen-require-mime
Open

fix(copilot): make stored MIME the source of truth for workspace file writes#6470
j15z wants to merge 1 commit into
stagingfrom
fix/ship-file-gen-require-mime

Conversation

@j15z

@j15z j15z commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • fixes agent edits silently reverting a workspace file's stored type (markdown -> txt on extension-less names): edit_content now preserves the record's stored content_type; an explicit contentType is the only way to change it
  • create_file now requires an explicit MIME — normalized (params stripped, lowercased) and shape-validated — instead of inferring from the name's extension; deletes the ext->MIME fallback and the unreachable workspace_file 'create' branch
  • regenerated tool catalog/schemas from the mothership schema change (mimeType required on outputs.files); includes a 2-line upstream OAuth description ride-along from mothership v0.8.10
  • regression tests for the exact reversion scenario plus the new failure paths

Type of Change

  • Bug fix

Testing

  • new tests: edit-content (4), create-file (5); files suite 59 pass
  • type-check, lint, check:api-validation, check:audits (22/22) pass

Deploy note

The mothership companion PR must merge first (to mothership staging): simstudioai/mothership#422. With old mothership + new sim, mimeType-less create_file calls fail with a self-describing error until the updated schema/prompt land; non-interactive replays would fail hard.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 9, 2026 2:11am

Request Review

@cursor

cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes copilot file write semantics (breaking for MIME-less create calls until mothership schema lands) and touches shared workspace file update paths, though behavior is tightened with tests rather than broad refactors.

Overview
Fixes copilot workspace file writes so stored MIME is authoritative instead of inferring type from filenames or extensions.

create_file now requires an explicit MIME (outputs.files[].mimeType or legacy contentType with fileName). Values are normalized (strip parameters, lowercase) and validated; missing or malformed MIME fails with guidance instead of inferring from .md etc. edit_content uses intent.contentType when set, otherwise keeps fileRecord.type, fixing silent markdown→plain regressions on extension-less names.

workspace_file drops the create operation and extension-based inferContentType; new files must use create_file. Generated tool catalog/schemas mark mimeType required and update descriptions accordingly.

Regression tests cover create-file MIME enforcement and edit-content type preservation.

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

@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes the stored MIME type authoritative for Copilot workspace-file writes and requires callers to declare a normalized MIME when creating files.

  • Preserves an existing file record’s MIME during update and patch operations unless an explicit conversion is requested.
  • Requires and validates MIME declarations for both modern outputs.files and legacy fileName create calls.
  • Regenerates the shared tool schemas/catalog and removes the unreachable workspace_file create implementation.
  • Adds focused regression and validation tests for create and edit behavior.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified in the changed paths.

The create path validates and consistently persists declared MIME values, the edit path preserves the authoritative stored type, and the removed workspace_file create branch was already unreachable under the generated schema.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/server/files/create-file.ts Requires an explicit MIME, normalizes and shape-validates it, and passes the normalized value consistently into the VFS writer.
apps/sim/lib/copilot/tools/server/files/edit-content.ts Replaces filename-extension inference with the stored file-record MIME while retaining explicit content-type conversion behavior.
apps/sim/lib/copilot/tools/server/files/workspace-file.ts Removes an unreachable create branch and extension-to-MIME inference while retaining existing update, append, patch, rename, and delete behavior.
apps/sim/lib/copilot/generated/tool-catalog-v1.ts Updates generated tool documentation and requires mimeType in create_file output declarations.
apps/sim/lib/copilot/generated/tool-schemas-v1.ts Mirrors the generated catalog contract by requiring mimeType for output-file creation.
apps/sim/lib/copilot/tools/server/files/create-file.test.ts Covers missing, malformed, normalized, legacy, and missing-path create-file inputs.
apps/sim/lib/copilot/tools/server/files/edit-content.test.ts Covers stored-type preservation, explicit conversion, patch writes, and absent-intent failure.

Sequence Diagram

sequenceDiagram
  participant M as Mothership
  participant C as create_file
  participant W as Workspace storage
  participant F as workspace_file
  participant E as edit_content
  M->>C: path + explicit mimeType
  C->>C: normalize and validate MIME
  C->>W: create file with stored MIME
  M->>F: select existing file for update/patch
  F->>E: store and consume file intent
  E->>W: read existing file record
  E->>E: use explicit conversion MIME or stored MIME
  E->>W: write content and authoritative MIME
Loading

Reviews (1): Last reviewed commit: "fix(copilot): make stored MIME the sourc..." | Re-trigger Greptile

@j15z
j15z force-pushed the fix/ship-file-gen-require-mime branch from f03bddc to 9c6495a Compare August 9, 2026 02:11
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.

1 participant