[PR #119] [MERGED] Plugin execution context #55

Closed
opened 2025-12-29 07:19:05 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mountain-loop/yaak/pull/119
Author: @gschier
Created: 10/1/2024
Status: Merged
Merged: 10/1/2024
Merged by: @gschier

Base: masterHead: plugin-execution-context


📝 Commits (2)

  • 422a581 Pass window label through to plugin calls
  • 8c106cb Better window context helpers

📊 Changes

29 files changed (+635 additions, -371 deletions)

View changed files

📝 plugin-runtime-types/package.json (+3 -1)
📝 plugin-runtime-types/src/bindings/events.ts (+9 -2)
plugin-runtime-types/src/bindings/serde_json/JsonValue.ts (+3 -0)
📝 plugin-runtime-types/src/plugins/Context.ts (+4 -0)
📝 plugin-runtime/src/index.worker.ts (+78 -30)
📝 src-tauri/src/http_request.rs (+6 -2)
📝 src-tauri/src/lib.rs (+163 -122)
📝 src-tauri/src/notifications.rs (+5 -5)
📝 src-tauri/src/render.rs (+24 -17)
📝 src-tauri/src/template_callback.rs (+26 -18)
📝 src-tauri/vendored/plugins/exporter-curl/package.json (+2 -10)
📝 src-tauri/vendored/plugins/filter-jsonpath/package.json (+4 -6)
📝 src-tauri/vendored/plugins/filter-xpath/package.json (+2 -7)
📝 src-tauri/vendored/plugins/importer-curl/package.json (+2 -9)
📝 src-tauri/vendored/plugins/importer-insomnia/package.json (+2 -7)
📝 src-tauri/vendored/plugins/importer-openapi/package.json (+2 -8)
📝 src-tauri/vendored/plugins/importer-postman/package.json (+2 -11)
📝 src-tauri/vendored/plugins/importer-yaak/package.json (+2 -10)
src-tauri/vendored/plugins/template-function-request/build/index.js (+64 -0)
src-tauri/vendored/plugins/template-function-request/package.json (+17 -0)

...and 9 more files

📄 Description

It's possible to for a call stack to look something like this:

app -> plugin -> app -> plugin -> app

If a plugin calls toast.show(), how does it know what window to show it on? The current implementation hacks it by always using the focused window (falling back to the main window if none focused) but this is problematic when plugins trigger requests, for example, because the runtime uses the window to get the current workspace and environment.

This PR eliminates the need for this hack by tacking on the initiating window label to every plugin call. This label is then added to every back-and-forth even until the call chain ends. This means the toast.show() handler can simply get the window from the window label on the given event.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mountain-loop/yaak/pull/119 **Author:** [@gschier](https://github.com/gschier) **Created:** 10/1/2024 **Status:** ✅ Merged **Merged:** 10/1/2024 **Merged by:** [@gschier](https://github.com/gschier) **Base:** `master` ← **Head:** `plugin-execution-context` --- ### 📝 Commits (2) - [`422a581`](https://github.com/mountain-loop/yaak/commit/422a581e6a43274e2d07026b51136cea3739df04) Pass window label through to plugin calls - [`8c106cb`](https://github.com/mountain-loop/yaak/commit/8c106cb2ed4321a1c6a492f33cc7bdedb5215f6c) Better window context helpers ### 📊 Changes **29 files changed** (+635 additions, -371 deletions) <details> <summary>View changed files</summary> 📝 `plugin-runtime-types/package.json` (+3 -1) 📝 `plugin-runtime-types/src/bindings/events.ts` (+9 -2) ➕ `plugin-runtime-types/src/bindings/serde_json/JsonValue.ts` (+3 -0) 📝 `plugin-runtime-types/src/plugins/Context.ts` (+4 -0) 📝 `plugin-runtime/src/index.worker.ts` (+78 -30) 📝 `src-tauri/src/http_request.rs` (+6 -2) 📝 `src-tauri/src/lib.rs` (+163 -122) 📝 `src-tauri/src/notifications.rs` (+5 -5) 📝 `src-tauri/src/render.rs` (+24 -17) 📝 `src-tauri/src/template_callback.rs` (+26 -18) 📝 `src-tauri/vendored/plugins/exporter-curl/package.json` (+2 -10) 📝 `src-tauri/vendored/plugins/filter-jsonpath/package.json` (+4 -6) 📝 `src-tauri/vendored/plugins/filter-xpath/package.json` (+2 -7) 📝 `src-tauri/vendored/plugins/importer-curl/package.json` (+2 -9) 📝 `src-tauri/vendored/plugins/importer-insomnia/package.json` (+2 -7) 📝 `src-tauri/vendored/plugins/importer-openapi/package.json` (+2 -8) 📝 `src-tauri/vendored/plugins/importer-postman/package.json` (+2 -11) 📝 `src-tauri/vendored/plugins/importer-yaak/package.json` (+2 -10) ➕ `src-tauri/vendored/plugins/template-function-request/build/index.js` (+64 -0) ➕ `src-tauri/vendored/plugins/template-function-request/package.json` (+17 -0) _...and 9 more files_ </details> ### 📄 Description It's possible to for a call stack to look something like this: ``` app -> plugin -> app -> plugin -> app ``` If a plugin calls `toast.show()`, how does it know what window to show it on? The current implementation hacks it by always using the focused window (falling back to the main window if none focused) but this is problematic when plugins trigger requests, for example, because the runtime uses the window to get the current workspace and environment. This PR eliminates the need for this hack by tacking on the initiating window label to every plugin call. This label is then added to every back-and-forth even until the call chain ends. This means the `toast.show()` handler can simply get the window from the window label on the given event. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 07:19:05 +01:00
adam closed this issue 2025-12-29 07:19:05 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/yaak#55