Skip to content

fix: run WorkspaceService PSCommands on the pipeline thread#4

Merged
dkattan merged 1 commit into
feature/get-content-host-packagefrom
fix/workspace-pipeline-thread
Jul 11, 2026
Merged

fix: run WorkspaceService PSCommands on the pipeline thread#4
dkattan merged 1 commit into
feature/get-content-host-packagefrom
fix/workspace-pipeline-thread

Conversation

@dkschruteBeets

Copy link
Copy Markdown
Collaborator

Summary

  • InvokePSCommand executes on the calling thread against the shared runspace, so calling it from LSP handler threads violated runspace thread affinity. EnumeratePSFiles and GetContent in WorkspaceService now route through a new ExecutePSCommandOnPipelineThread helper that queues onto the pipeline thread via ExecutePSCommandAsync unless the caller is already on it (guarded by a new internal PsesInternalHost.IsPipelineThread property, which prevents self-deadlock when blocking on the queued task).
  • Broadens the ObjectNotFound catch in GetContent: the FileSystem provider reports missing paths as string[], but other providers report a plain string, so their misses previously leaked out as raw ActionPreferenceStopException instead of FileNotFoundException.

Why

Needed for PSPath-backed script files in ImmyBot (feat/pspath-script-provider). Reading workspace files through a custom PSProvider from LSP request threads intermittently corrupted the runspace due to the thread-affinity violation. Once merged, ImmyBot bumps the editor services package to preview.6 built from feature/get-content-host-package.

Testing

Verified against a live ImmyBot session: PSPath-backed files load through GetContent from LSP handler threads without runspace errors, and missing PSPath files surface as FileNotFoundException matching FileSystem behavior.

🤖 Generated with Claude Code

InvokePSCommand executes on the calling thread against the shared
runspace, so calling it from LSP handler threads violated runspace
thread affinity. Route EnumeratePSFiles and GetContent through the
pipeline thread task queue unless already on it.

Also broaden the ObjectNotFound catch in GetContent so non-FileSystem
providers, which report the missing path as a plain string instead of
a string[], surface FileNotFoundException like the FileSystem provider.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dkschruteBeets dkschruteBeets self-assigned this Jul 10, 2026
@dkattan
dkattan merged commit 99b5746 into feature/get-content-host-package Jul 11, 2026
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.

2 participants