Skip to content

fix(editor): reject lock files with no workspace match for cwd#24323

Merged
jlongster merged 1 commit intoanomalyco:devfrom
jjjermiah:fix/editor-cross-directory-lock-injection
Apr 26, 2026
Merged

fix(editor): reject lock files with no workspace match for cwd#24323
jlongster merged 1 commit intoanomalyco:devfrom
jjjermiah:fix/editor-cross-directory-lock-injection

Conversation

@jjjermiah
Copy link
Copy Markdown
Contributor

without a minimum score threshold, opencode would connect to any VSCode lock file in ~/.claude/ide/ even when the workspace folders had no relation to the current working directory. This caused cross-directory IDE context injection

  • e.g. a WezTerm session in an unrelated dir receiving file-open events from a VSCode window

Issue for this PR

Closes #24295

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • instead of just accepting any of lockfiles, regardless of if the paths matched my cwd
  • filter lock files to only those whose workspaceFolders contain cwd before sorting.
  • Replace the binary pathContains check with pathContainsLength so the sort can prefer the most specific (deepest) workspace match, falling back to mtime for ties.

How did you verify your code works?

  • ran bun dev from the opencode repo with VSCode open in the same workspace
    • confirmed selection_changed events are still received for files within the workspace
  • ran from another workspace with the vscode ide still open, and verified that a lock file from an unrelated VSCode workspace is rejected by the filter.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Without a minimum score threshold, opencode would connect to any
VSCode lock file in ~/.claude/ide/ even when the workspace folders
had no relation to the current working directory. This caused
cross-directory IDE context injection — e.g. a WezTerm session in
an unrelated dir receiving file-open events from a VSCode window.

Filter lock files to only those whose workspaceFolders contain cwd
before sorting. Replace the binary pathContains check with
pathContainsLength so the sort can prefer the most specific
(deepest) workspace match, falling back to mtime for ties.

Removes scoreEditorLock which is no longer needed.
@jlongster jlongster force-pushed the fix/editor-cross-directory-lock-injection branch from c146a7e to bdde58c Compare April 26, 2026 18:20
@jlongster
Copy link
Copy Markdown
Contributor

great catch, thank you! I tested this and looks like it's working well, will merge

@jlongster jlongster merged commit dcee1c3 into anomalyco:dev Apr 26, 2026
8 checks passed
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.

Stale "Note: The user opened the file ..." leaks across sessions and projects

2 participants