Skip to content

feat(files): surface file versions in the File block and logs, with conditional writes - #8056

Merged
waleedlatif1 merged 8 commits into
stagingfrom
feat/file-version-surfaces
Sep 20, 2026
Merged

waleedlatif1 merged 8 commits into
stagingfrom
feat/file-version-surfaces

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • File block write/append/edit report the version their write recorded, and Get File reports the version it read; a file created with its content is version 1
  • Execution files carry the version of the workspace file they resolved from, so it shows on the log file card and is referenceable as <file.version>
  • Write and edit accept an optional expectedRevision — the opaque token Get File and every write return — and refuse the write when the content moved on. It maps onto the content guard the storage layer already enforces under its row lock, so the check is atomic and costs no extra read
  • expectedRevision on a write requires overwrite: true, refused at parse time rather than after uploading bytes and creating folders

Version numbers deliberately do NOT drive the precondition: collaborative and workflow writes coalesce into the current version rather than adding one, so the same number can name different bytes. The revision is contentUpdatedAt, which advances on every content write.

Everything is additive and optional: no field changes shape for existing callers, old log rows without a version still parse and render, no subblock ids changed, and earlier File block generations are untouched. An unconditional write reads nothing extra.

Type of Change

  • New feature

Testing

  • 54,486 sim unit tests, 1,165 CLI tests, 56 docs tests; lint, check:audits, docs-manifest:check and type-check all pass
  • New tests cover the write and edit preconditions (guard uses the caller's revision, invalid revision refused, storage conflict surfaced, unconditional write reads nothing) and that the display filter keeps the version; each was verified to fail without its fix
  • The file-version Postgres integration suite could not run locally (Docker unresponsive on this machine) — it runs in the PostgreSQL integration job on this PR

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 Sep 20, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 20, 2026 4:30am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previously reported issues are resolved and no new actionable defects remain.

Summary

This PR surfaces workspace-file versions and opaque content revisions across File block outputs, execution logs, and v2 APIs while adding atomic conditional writes and reverts.

  • Returns versions and revisions from relevant reads and writes.
  • Enforces expectedRevision through the existing storage transaction and conflict handling.
  • Preserves file versions in execution-file serialization and log rendering.
  • Adds guarded version enrichment for folder-selected files.
  • Updates generated contracts, CLI documentation, tests, and OpenAPI artifacts.
Diagram
sequenceDiagram
    participant Caller
    participant FileAPI as File block / v2 API
    participant Storage as Workspace file storage
    participant Versions as Version history

    Caller->>FileAPI: Read file
    FileAPI->>Storage: Load current file
    FileAPI->>Versions: Resolve current version
    FileAPI-->>Caller: Content metadata + version + revision

    Caller->>FileAPI: Write(expectedRevision)
    FileAPI->>Storage: Atomically compare revision and write
    alt Revision matches
        Storage->>Versions: Record or coalesce version
        FileAPI-->>Caller: Updated file + version + new revision
    else Content changed
        FileAPI-->>Caller: 409 Conflict
    end
Loading

Reviews (8) · Last reviewed commit: "feat(files): number folder-selected read..."

Comment thread apps/sim/lib/logs/execution/logger.ts Outdated
Comment thread apps/sim/lib/workspace-files/application/update-workspace-file-content.test.ts Outdated
@greptile-apps

This comment has been minimized.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 27 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/api/contracts/tools/file.ts
Comment thread apps/sim/lib/internal/file/operations.ts
Comment thread apps/sim/lib/workspace-files/application/update-workspace-file-content.ts Outdated
Comment thread apps/sim/lib/internal/file/operations.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 27 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 39 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/api/contracts/v2/files.ts Outdated
Comment thread apps/sim/lib/api/contracts/v2/file-versions.ts
Comment thread apps/docs/openapi-v2-files-audit.json Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 39 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/docs/openapi-v2-files-audit.json
Comment thread apps/sim/lib/api/contracts/v2/files.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/lib/api/contracts/v2/files.ts

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 40 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 41 files

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/api/contracts/v2/files.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 42 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Addressed both findings from the outside-diff list:

  • Folder Files Lose Versions — folder-selected reads are now numbered too. Their ids go through one batched read that returns each file's key alongside its current version, and the number is attached only where that key still matches the listed row, so a file rewritten since the listing is left without a version rather than given one for bytes it no longer holds. Explicit ids keep using the versioned metadata read.
  • Property Documentation Is Non-TSDoc — converted that comment in tools/file/write.ts.

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 42 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 7689dcc into staging Sep 20, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/file-version-surfaces branch September 20, 2026 04:57

This branch was previously deployed

1 inactive deployment
Preview b9e23c57 Deployed Sep 20, 2026 by vercel[bot]
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