Skip to content

fix: unwrap action parameters and capture query settings in v2 protocol#27

Merged
Garulf merged 2 commits into
mainfrom
fix/v2-action-params
Jul 10, 2026
Merged

fix: unwrap action parameters and capture query settings in v2 protocol#27
Garulf merged 2 commits into
mainfrom
fix/v2-action-params

Conversation

@Garulf

@Garulf Garulf commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Problem

In the V2 (python_v2) protocol, methods registered via Result.add_action were triggered without their parameters — multi-parameter methods failed with a swallowed TypeError ("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.settings was never populated under V2.

Root cause

Flow Launcher's V2 host executes actions via StreamJsonRpc's single-argument overload:

RPC.InvokeAsync<JsonRPCExecuteResponse>(result.JsonRPCAction.Method, argument: result.JsonRPCAction.Parameters);

That overload wraps the entire Parameters list in a one-element array, so the wire message is "params": [["a", "b"]] — unlike V1's "parameters": ["a", "b"]. FlowLauncherV2.run passed it straight to dispatch(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-level settings key was being read.

Changes

  • FlowLauncherV2.run unwraps the single-element list wrapping for action methods before dispatch. context_menu is explicitly excluded (its single list argument is the ContextData, matching V1 behavior), and query keeps its existing special case.
  • FlowLauncherV2.run stores params[1] of query requests as the launcher settings; the top-level settings key remains as a fallback.
  • New integration tests: TestV2Actions (parameters unwrapped, empty-parameter actions, execute-response shape, context_menu V1 parity) and two TestV2Settings cases (settings captured from query params and not leaked into handler arguments).
  • Ignore uv.lock.

Reapplies 342574f and fe2376e (reverted off main in 0f5d2bc/c056e77 so this lands via PR review).

Garulf added 2 commits July 10, 2026 08:02
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 }).
@Garulf Garulf merged commit 0f9c100 into main Jul 10, 2026
5 checks passed
@Garulf Garulf deleted the fix/v2-action-params branch July 10, 2026 08:05
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.

1 participant