[Feature request] Running request folder via Plugin API should show latest response data
- Dominant language
- TypeScript
- Stars
- 40k
- Forks
- 2.4k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 61
Description
### Expected Behavior
When a plugin triggers a request (via [`network.sendRequest`](https://docs.insomnia.rest/insomnia/context-object-reference#contextnetwork)), that response should appear on the response history dropdown, as the responses of manually-triggered requests do.
### Actual Behavior
Plugin-initiated responses don't appear on the history dropdown until a request is sent manually (with the Send button), at which point all the responses that were caused by the plugin, plus the recently-made manual request, all appear at once
### Reproduction Steps
1. Install a plugin that programmatically makes requests (see on Additional information for a minimal repro). The [Send Request example in the docs](https://docs.insomnia.rest/insomnia/hooks-and-actions#example-send-request) is enough to cause the issue
2. Create a new request
3. Execute the plugin on the request (via the request's context menu)
4. The response history for the request should contain a new entry, but it doesn't. If it was the first call of the request (or the first call after clearing the history) the button for the history dropdown won't even appear (as it doesn't if there are no responses yet)
5. Manually send the request
6. The history button will appear and contain two entries (one for the plugin-initiated response, and one for the manual one)
### Is there an existing issue for this?
- [X] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.
### Additional Information
This was reported on a Insomnia plugin that I maintain. See https://github.com/jreyesr/insomnia-plugin-batch-requests/issues/10. However, I can reproduce it with a very simple plugin too, taken directly from the docs, so it appears to be general and thus I'm reporting it here.
To reproduce the issue, you can use the following minimal plugin:
package.json
```json
{
"name": "insomnia-plugin-repro-history",
"version": "0.0.1",
"private": true,
"insomnia": {
"name": "repro-history",
"description": ""
},
"main": "main.js"
}
```
main.js
```js
module.exports.requestActions = [
{
label: "Send request",
action: async (context, data) => {
const { request } = data;
const response = await context.network.sendRequest(request);
const html = `${request.name}: ${response.statusCode}`;
context.app.showGenericModalDialog("Results", { html });
},
},
];
```
### Insomnia Version
2023.5.8
### What operating system are you using?
Windows
### Operating System Version
Ubuntu 22.04
### Installation method
APT (.deb file)
### Last Known Working Insomnia version
2022.5.7
Contributor guide
Research direction
Reproduce the issue with the documented requestActions example and its call to context.network.sendRequest(request), then trace how plugin-triggered responses reach the response history dropdown. Compare that path with the manual Send action; done means each plugin response appears in the request's history immediately, including the first response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100