t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Remote Markdown preview opens as a folder in VS Code/VSCodium (ENOTDIR)

Open KyleKincer opened this issue 1 month ago • 3 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/web, packages/contracts

Summary

Preserving the remote-file opening problem from #10824 and #15199, as requested in the closure of #18215.

Opening a Markdown file from its preview can connect successfully over SSH but hand the file path to the editor as a folder. Opening the project works.

Steps to reproduce

These steps describe the linked reports; this filing does not claim a fresh live reproduction.

  1. Connect T3 Code to a remote environment with a working SSH editor route.
  2. Open a project containing an existing, readable Markdown file.
  3. Confirm the project's Open action opens the project in the local editor over SSH.
  4. Open the Markdown file in T3's file preview.
  5. Select VS Code or VSCodium in the preview's editor picker and press Open.

Expected behavior

The editor opens the previewed remote file. Project and directory targets continue to open as folders.

Actual behavior

SSH connects, but the editor treats the Markdown file as a folder and leaves an empty window. One report records ENOTDIR while looking for <file>.md/.vscode.

Original reports:

  • bsteuber, September 11: Arch Linux/VSCodium client, remote Ubuntu T3 server. Project Open works; Markdown-preview Open leaves an empty editor. Appending :1:1 to the same file URL opens the file.
  • Abdullah1738, October 8: T3 on a Mac, opening files from a laptop over Tailscale with Remote-SSH. The Markdown file opens as a folder workspace and produces ENOTDIR. The reporter also confirmed the earlier fix branch worked locally.

Impact

Minor bug or occasional failure.

The remote preview-to-editor action fails for the reported files. Opening the project and navigating to the file is a workaround.

Version or commit

  • #15199 records the defect on V2 main at f391794a.
  • Source inspected October 15 at main 00cdceb196edf661652dee6efe983c0d40662971: file/folder identity is still absent from this path.
  • Exact T3/editor release versions were not supplied in the original reports.
  • No live SSH/editor session or test suite was rerun for this issue.

Environment

Reported setups: Arch Linux/VSCodium → Ubuntu, and a laptop using VS Code/Remote-SSH over Tailscale to T3 on a Mac. The second report does not specify the laptop's OS.

Logs or stack traces

Reported error: ENOTDIR on <file>.md/.vscode. A complete stack trace was not supplied.

Protocol evidence

Generated URL shape for an ordinary Markdown file:

vscode://vscode-remote/ssh-remote+HOST/absolute/path/file.md

Independently confirmed working form:

vscode://vscode-remote/ssh-remote+HOST/absolute/path/file.md:1:1

HOST and the path are placeholders; the reported comparison used the same real host and file.

VS Code's remote protocol handler classifies this ordinary path as a file when it ends in a numeric position; otherwise it returns a folder target.

On the inspected T3 main:

Screenshots, recordings, or supporting files

Historical evidence from #10824: before, after, recording.

That PR describes capturing the preview action's URL and replaying it through VS Code's handler because the embedded test browser did not launch the custom scheme. These are historical artifacts, not new V2 screenshots.

Workaround

Open the remote project and navigate to the file. For an ordinary file path, manually appending :1:1 also worked in the linked report.

Scope for triage

Preserve a known preview target's file/folder identity through the existing picker and remote URL builder, with focused regression coverage for the preview-file action and project-folder control. Directory and read-error states should not be blindly marked as files. This issue focuses on the original ordinary-file failure so a contained fix can be scoped before another PR.

Prepared with Codex from the linked reports and source inspection.

KyleKincer avatar Oct 15 '26 10:10 KyleKincer

[!NOTE] Grok responding on behalf of Julius.

Confirmed on main: buildRemoteOpenUrl (packages/contracts/src/editor.ts) emits vscode://vscode-remote/ssh-remote+HOST/path with no file/folder hint, and OpenInPicker passes the preview's absolute path through unchanged. The linked reports show VS Code opening that link as a folder (ENOTDIR), while the same URL with :1:1 opens the file.

The earlier PRs were closed for process reasons, not because the bug was rejected. #10824 conflicted with the V2 rewrite, #15199 was part of a PR cleanup, and #18215 went over the 500-line limit for outside PRs.

Workaround for now: open the project and navigate to the file, or add :1:1 to the end of the file URL.

A focused fix would mark file targets in the VS Code-family branch (for example by appending :1:1) and leave project/folder opens as they are.

juliusmarminge avatar Oct 15 '26 10:10 juliusmarminge

Reproduced on T3 Code Alpha 0.0.45 (macOS 27.0.1, VS Code 1.142.0, remote host reached over Tailscale/SSH), with two symptoms not yet listed here:

  1. Dialog text: VS Code opens a new remote window showing "Workspace does not exist. Please select another workspace to open." VS Code's stored window state records the file itself as the window's folder: {"folder": "vscode-remote://ssh-remote+my-host/home/user/project/notes/README.md"}.
  2. The existing window gets replaced. With default VS Code settings, the bogus folder window replaced my already-open window instead of opening alongside it.

Why (2) happens, from VS Code source at 085f2be:

  • getWindowOpenableFromProtocolUrl returns folderUri for a remote path unless it has a workspace-file extension or matches /:[\d]+$/ (app.ts L1059-L1068). windowId=_blank is removed before this check, so it doesn't change file-vs-folder.
  • forceNewWindow is only true with windowId=_blank (or on macOS with no windows open) (app.ts L1105-L1120). With window.openFoldersInNewWindow: "default", a folder open then reuses an existing window (windowsMainService.ts L1363-L1373).

So the fix in #19898 (append :1:1 for file targets in the VS Code-family branch) should fix both symptoms. The protocol open uses gotoLineMode: true, so the suffix becomes the cursor position and isn't treated as part of the path (windowsMainService.ts L1131-L1141). I haven't tested #19898 itself.

Main at a356999 still emits the path-only URL (editor.ts L180-L214).

MarcRez33 avatar Oct 18 '26 19:10 MarcRez33

[!NOTE] Grok responding on behalf of Julius.

Fixed by #19898, which just merged to main: remote file previews now open as files in VS Code-family editors (the URL gets :1:1) instead of as a folder, so the ENOTDIR case should be gone. Project and folder links still open as folders. If you still hit this on a build that includes #19898, please open a new issue with the editor and versions.

juliusmarminge avatar Oct 20 '26 04:10 juliusmarminge