Skip to content

about opencode's vscode extension #15461

@Mathew149

Description

@Mathew149

Description

GitHub Issue for OpenCode

Title

incorrect file reference format "In @" when opening OpenCode from VSCode (Windows)

Issue Description

When opening OpenCode from VSCode extension on Windows, the file reference format in the dialog shows incorrect formatting:

Current behavior:

  • Shows: In @Homework/file name
  • The "In " prefix is unnecessary
  • File path uses forward slash / instead of Windows backslash \

Expected behavior:

  • Should show: @Homework\file name
  • No "In " prefix
  • Use correct Windows path separator \

Environment

  • OS: Windows 10/11
  • VSCode extension: sst-dev.opencode version 0.0.13
  • Extension file: ~/.vscode/extensions/sst-dev.opencode-0.0.13/dist/extension.js

Reproduction Steps

  1. Open a file in VSCode on Windows (e.g., a file in Homework folder)
  2. Use VSCode keyboard shortcut (Ctrl+Esc) to open OpenCode
  3. Observe the text automatically inserted in the OpenCode dialog
  4. The text shows: In @Homework/文件

Root Cause Analysis

Found in /dist/extension.js (compressed code):

Issue 1: "In " prefix

// Line around 32 in the compressed code
c&&(await h(t,`In ${r}`),n.show())

Should be:

c&&(await h(t,`${r}`),n.show())

Issue 2: Path separator

// Path generation logic
c=`@${o.workspace.asRelativePath(n.uri)}`

VSCode's asRelativePath() API returns relative paths with OS-specific separators, but on Windows it should convert to backslash \ for consistency with Windows file path conventions.

Possible Fix

Fix 1 - Remove "In " prefix:

In extension.js, change:

await h(t,`In ${r}`)

to:

await h(t,`${r}`)

Fix 2 - Convert path separator for Windows:

Option A: In the VSCode extension, modify the path generation:

c=`@${o.workspace.asRelativePath(n.uri).replace(/\//g, "\\")}`

Option B: Better approach - Handle this in the OpenCode server side to normalize paths regardless of OS:

  • Convert all paths to Unix format with / for cross-platform consistency
  • Or preserve OS-specific format based on client OS

Additional Context

  • The @ syntax for file references is great
  • The automatic file context when opening from VSCode is a useful feature
  • Only the formatting needs adjustment for better UX on Windows

Alternative

Consider using Unix-style paths (@Homework/file name) universally if the backend handles paths in a platform-agnostic way, which might be simpler than OS-specific formatting.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwebRelates to opencode on web / desktopwindows

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions