Registry Mirror
Skip to content

Conversation

@iamshadmantaqi

Copy link
Copy Markdown
Contributor

Problem

An extensionless script whose shebang uses env to set the program's argv[0] gets the generic file icon in the composer instead of the JavaScript icon.

Steps (web build on Linux, no provider sign-in needed):

  1. In a project, create an extensionless file run whose first line is #!/usr/bin/env -a myapp node, followed by a console.log line. #!/usr/bin/env --argv0 myapp node behaves the same.
  2. Use the Files panel "Add to chat" on the file, or mention it with @run.
  3. The chip shows the generic file icon, because the server reports no mimeType at all.

The same file with #!/usr/bin/env -u FOO node shows the JavaScript icon, since #45465.

Cause

apps/server/src/workspace/fileHeaderMimeType.ts line 30. The env loop skips two words after an option only for -[uCP], --unset and --chdir. GNU env's -a and --argv0 also take a separate value (the program's argv[0]), so that value is taken as the program and the real interpreter is never reached.

Change

-a and --argv0 join the option list #45465 touched, so the loop skips their value and reads the program after it. One line changed in fileHeaderMimeType.ts.

Scope

Small fix of an obvious bug, steps reproduce it, so it needs no issue.

Verification

WorkspaceFileSystem.test.ts gains a case beside the existing env -u fixture, "treats env -a and --argv0 as options so the icon follows the program", which writes #!/usr/bin/env -a myapp node and #!/usr/bin/env --argv0 myapp node scripts and expects text/javascript for both.

Test commit alone, fails on main 58a4e59:

FAIL  src/workspace/WorkspaceFileSystem.test.ts > WorkspaceFileSystemLive > getMetadata > treats env -a and --argv0 as options so the icon follows the program
  actual: [
    { kind: 'file', byteLength: 50 },
    { kind: 'file', byteLength: 55 }
  ],
  expected: [
    { kind: 'file', byteLength: 50, mimeType: 'text/javascript' },
    { kind: 'file', byteLength: 55, mimeType: 'text/javascript' }
  ],
Tests  1 failed | 32 passed | 1 skipped (34)

With the fix, the whole file:

Test Files  1 passed (1)
Tests  33 passed | 1 skipped (34)

The skip is a pre-existing skipIf case in that file, not this one.

vp run check:changed: format, lint, knip 1/2 and 2/2, graphql (apps/server), typecheck (3 packages) and test (2 files) all pass.

Not verified: I did not add the file in the running app; the test calls the server's getMetadata for the file, which is what the chip's icon reads.

Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 29, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at ec0c89c

Macroscope's review found this PR approvable — Recognizes env -a and --argv0 arguments so extensionless scripts retain their interpreter-specific file type and icon. The change is limited to metadata detection and leaves file access and execution behavior unchanged.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The env shebang parser now skips values for -a and --argv0 before identifying the interpreter. Tests cover extensionless scripts and verify their JavaScript MIME types and byte lengths.

Changes: Shebang metadata detection

Layer / File(s) Summary
Skip argv0 values during interpreter detection
apps/server/src/workspace/fileHeaderMimeType.ts, apps/server/src/workspace/WorkspaceFileSystem.test.ts
The parser treats -a and --argv0 as options with following values. Tests cover both shebang forms and verify JavaScript MIME types and byte lengths.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: saphid, juliusmarminge, lucenx9

Merge Risk: Minimal · up to c0e29

Extensionless scripts whose shebangs use env -a or --argv0 should now keep their JavaScript file type and icon. No actionable merge risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the actual change: the shebang parser now treats the -a and --argv0 env options as taking a separate value, so the interpreter file type is kept. This matches the raw summary and t…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives reproduction steps and the environment. The Change section names the one-line …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: the shebang parser now treats the -a and --argv0 env options as taking a separate value, so the interpreter file type is kept. This matches the raw summary and the objectives. The title follows the conventional commit format. It is 71 characters, which is acceptable.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section gives reproduction steps and the environment. The Change section names the one-line edit in fileHeaderMimeType.ts. The Scope section explains why no issue is linked. The Verification section gives the failing test output before the fix, the passing output after it, and the lint and typecheck results. It also states what was not verified. The author also names the model and harness, as the template asks. The template asks for a conventional commit title, and the title does that.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ec0c89c and c0e297d.

Files selected for processing: 2

  • apps/server/src/workspace/WorkspaceFileSystem.test.ts
  • apps/server/src/workspace/fileHeaderMimeType.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

# Conflicts:
#	apps/server/src/workspace/fileHeaderMimeType.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant