Skip to content

fix(files): read offset 0 as the first line instead of rejecting it - #8588

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/chat-tool-ergonomics
Oct 2, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/chat-tool-ergonomics

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • files read --offset 0 failed with offset starts at line 1. Callers used to zero-based paging (agents in particular) send 0 for the first window, and this was the most common argument error the Chat agent hit with sim_cli, at about 30 a day.
  • offset now accepts 0 and reads it as the first line. The response's lineRange.offset still reports 1, so the caller learns the 1-based convention from the result. A negative offset is still rejected.
  • This applies to both contracts that take a file line window: v2 GET /files/{id}/text (and files versions read, which shares the schema), and the File block's content operation that Agent-block LLMs call.
  • sliceFileTextLines already clamped a start below line 1, so no reader changes were needed. A new test pins that clamp, since the relaxed contract now relies on it.
  • Regenerated the OpenAPI document, the sim CLI API, and the CLI docs: minimum goes from 1 to 0, and the description says 0 starts at the first line.

Type of Change

  • Bug fix

Testing

  • Red-first, so each new case fails on the pre-fix code:
    • route.test.ts (v2 text): offset=0 returns 200.
    • operations.test.ts: the File block's content op with offset: 0 returns the first line and reports lineRange.offset: 1.
    • text-lines.test.ts: removing the clamp turns the offset-0 case red.
  • file-read.test.ts: the engine's reject list now uses -1 instead of 0.
  • bun run lint, bun run type-check (apps/sim), check:api-validation:strict, check:audits, docs-manifest:check, block-registry check, and root bun run test all passed.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • 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 Oct 2, 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 Oct 2, 2026 9:59pm UTC

Request Review

@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 Oct 2, 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 10 files

Confidence score: 5/5

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

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Changes file read API to accept offset zero.

The offset-zero behavior appears correct, but the CLI test must satisfy the repository’s explicit testing requirement before merging.

Findings

  1. P2 Mock-call assertion in new test ▶

Summary

The PR accepts offset 0 as the first line in file-read contracts, updates generated API descriptions and CLI documentation, and adds regression coverage.

  • The newly added CLI test violates the repository’s explicit testing rule against mock-call assertions.

Reviews (2) · Last reviewed commit: "test(files): cover the agent CLI forward..."

Comment thread apps/sim/lib/mothership/agent-cli/engines/file-read.test.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 Oct 2, 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 10 files

Confidence score: 5/5

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

Re-trigger cubic

Comment thread apps/sim/lib/mothership/agent-cli/engines/file-read.test.ts
@waleedlatif1
waleedlatif1 enabled auto-merge (squash) October 2, 2026 22:09
@waleedlatif1
waleedlatif1 merged commit 19abda3 into staging Oct 2, 2026
24 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-tool-ergonomics branch October 2, 2026 22:10

This branch was previously deployed

1 inactive deployment
Preview — ef6bb7b8 Deployed Oct 2, 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