fix: unwrap action parameters and capture query settings in v2 protocol#27
Merged
Conversation
Flow Launcher's V2 host executes JsonRPCActions via StreamJsonRpc's
single-argument InvokeAsync overload, which wraps the whole Parameters
list as one positional argument (params=[[p1, p2]]). Unwrap it before
dispatch so action methods receive their parameters like V1.
context_menu is excluded: its single list argument is the ContextData.
Also store plugin settings from the second query param, matching
InvokeWithCancellationAsync("query", new object[] { query, Settings.Inner }).
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.
Problem
In the V2 (
python_v2) protocol, methods registered viaResult.add_actionwere triggered without their parameters — multi-parameter methods failed with a swallowedTypeError("Internal error" response), and single-parameter methods received the whole parameters list as one argument. This also broke actions attached to context-menu results. Additionally,plugin.settingswas never populated under V2.Root cause
Flow Launcher's V2 host executes actions via StreamJsonRpc's single-argument overload:
That overload wraps the entire
Parameterslist in a one-element array, so the wire message is"params": [["a", "b"]]— unlike V1's"parameters": ["a", "b"].FlowLauncherV2.runpassed it straight todispatch(method, *params), giving the method one list argument instead of its unpacked parameters.Settings are sent by the V2 host as the second query param (
InvokeWithCancellationAsync("query", new object[] { query, Settings.Inner })), but only a top-levelsettingskey was being read.Changes
FlowLauncherV2.rununwraps the single-element list wrapping for action methods before dispatch.context_menuis explicitly excluded (its single list argument is the ContextData, matching V1 behavior), andquerykeeps its existing special case.FlowLauncherV2.runstoresparams[1]of query requests as the launcher settings; the top-levelsettingskey remains as a fallback.TestV2Actions(parameters unwrapped, empty-parameter actions, execute-response shape, context_menu V1 parity) and twoTestV2Settingscases (settings captured from query params and not leaked into handler arguments).uv.lock.Reapplies 342574f and fe2376e (reverted off
mainin 0f5d2bc/c056e77 so this lands via PR review).