Skip to content

fix(files): uniquify materialized upload names - #6273

Open
j15z wants to merge 3 commits into
stagingfrom
fix/mship-materialize-name-collision
Open

fix(files): uniquify materialized upload names#6273
j15z wants to merge 3 commits into
stagingfrom
fix/mship-materialize-name-collision

Conversation

@j15z

@j15z j15z commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • allocate an unused root-level workspace file name before materializing uploads
  • retry exact name-index collisions with the next suffix while preserving replay and storage accounting
  • return the final persisted name in materialize_file results so Mothership can address renamed files

Type of Change

  • Bug fix

Testing

  • 54 related Vitest tests passed
  • TypeScript type-check passed
  • API validation and changed-file lint checks passed
  • full ship generators, lint, and CI audit checks passed
  • manually verified trace 6725ea941acc0d4547de9a741f288284 returned dogs (2).pdf and Mothership used the chosen name

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)

@vercel

vercel Bot commented Aug 5, 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 5, 2026 1:55am

Request Review

@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

PR Summary

Cursor Bugbot is generating a summary for commit 26e6206. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes upload materialization allocate an unused root-level workspace filename and preserves the selected name across persisted metadata and replay responses.

  • Retries transactions when the workspace filename uniqueness constraint detects a concurrent collision.
  • Resolves replayed materializations from the current workspace-file record.
  • Adds tests for suffix allocation, collision retries, retry exhaustion, unrelated uniqueness errors, and replay behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/handlers/materialize-file.ts Adds unique root-name allocation, targeted collision retries, synchronized persisted names, and replay lookup without an eligible follow-up defect.
apps/sim/lib/copilot/tools/handlers/materialize-file.test.ts Expands coverage for allocation, collision handling, bounded retries, storage accounting, and replay outcomes.

Sequence Diagram

sequenceDiagram
  participant C as Materialize caller
  participant A as Name allocator
  participant DB as PostgreSQL
  C->>A: Allocate root-level filename
  A->>DB: Check available names
  A-->>C: Candidate filename
  C->>DB: Transition upload in transaction
  alt Filename collision
    DB-->>C: Targeted unique violation
    C->>A: Allocate again
  else Transition succeeds
    DB-->>C: Materialized workspace file
  else Transition already completed
    C->>DB: Read current workspace file
    DB-->>C: Replayed file metadata
  end
Loading

Reviews (2): Last reviewed commit: "fix(files): sync materialized display na..." | Re-trigger Greptile

Comment thread apps/sim/lib/copilot/tools/handlers/materialize-file.ts
@j15z

j15z commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 902de3f. Configure here.

@j15z
j15z force-pushed the fix/mship-materialize-name-collision branch from 902de3f to bbf7a55 Compare August 5, 2026 01:54
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