Fix copilot process startup crash and model selector not applying selection#61
Merged
Fix copilot process startup crash and model selector not applying selection#61
Conversation
…ection CopilotService: Set explicit Cwd on CopilotClientOptions When PolyPilot is launched from the staging directory via relaunch.sh, the process working directory resolves to the .app bundle path (/Users/.../bin/staging/PolyPilot.app). The SDK's CopilotClient uses this as the working directory when spawning the 'copilot' CLI process, which fails with 'No such file or directory' because .app bundles are not valid working directories for child processes on macOS. Fix: Set CopilotClientOptions.Cwd = ProjectDir so the copilot CLI process always starts with the project source directory as its working directory, regardless of where the .app bundle is running from. ModelSelector: Fix dropdown selection being ignored (focusout race) The ModelSelector component had @onfocusout="Close" on the parent div and @OnClick handlers on dropdown options. When clicking a model option, the browser's focus-change sequence fires focusout before the click event. This caused Close() to set isOpen=false, triggering a Blazor re-render that removed the dropdown from the DOM before the Select() click handler could execute. The result was that the dropdown closed without applying the selection, snapping back to the default model. Fix: Add @onmousedown:preventDefault="true" on the dropdown container. This prevents the browser's default mousedown behavior (moving focus away from the currently focused element), so focusout does not fire before the click event. The click on the model option now fires normally, Select() executes, and the chosen model is applied.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CopilotService: Set explicit Cwd on CopilotClientOptions
When PolyPilot is launched from the staging directory via relaunch.sh, the process working directory resolves to the .app bundle path (/Users/.../bin/staging/PolyPilot.app). The SDK's CopilotClient uses this as the working directory when spawning the 'copilot' CLI process, which fails with 'No such file or directory' because .app bundles are not valid working directories for child processes on macOS.
Fix: Set CopilotClientOptions.Cwd = ProjectDir so the copilot CLI process always starts with the project source directory as its working directory, regardless of where the .app bundle is running from.
ModelSelector: Fix dropdown selection being ignored (focusout race)
The ModelSelector component had @onfocusout="Close" on the parent div and @OnClick handlers on dropdown options. When clicking a model option, the browser's focus-change sequence fires focusout before the click event. This caused Close() to set isOpen=false, triggering a Blazor re-render that removed the dropdown from the DOM before the Select() click handler could execute. The result was that the dropdown closed without applying the selection, snapping back to the default model.
Fix: Add @onmousedown:preventDefault="true" on the dropdown container. This prevents the browser's default mousedown behavior (moving focus away from the currently focused element), so focusout does not fire before the click event. The click on the model option now fires normally, Select() executes, and the chosen model is applied.