feat(send): link every response to the request version that produced it

HTTP snapshots in resolve_send_inputs, the last point in the pipeline that
still holds the stored request — below it the request has been resolved against
its folder and workspace and then rendered, and neither is what a restore
should put back. Every host reaches sending through that function, so the
desktop, the CLI and plugin-triggered sends all get versions without each
knowing about them. gRPC and WebSocket connect do the same at their connection
upserts.

snapshot_request_for_send swallows its own errors: a send is not worth failing
over history that couldn't be written, and an ephemeral request has no id to
version. Either way the response just has no version to offer.
This commit is contained in:
Gregory Schier
2026-09-05 21:05:34 -07:00
parent 77fe1367a0
commit 19a43e3785
4 changed files with 53 additions and 3 deletions
+8
View File
@@ -40,6 +40,7 @@ use yaak_models::models::{
CookieJar, Environment, GrpcConnection, GrpcConnectionState, GrpcEvent,
GrpcEventType, HttpRequest, HttpResponse, HttpResponseState, Workspace,
};
use yaak_models::queries::any_request::AnyRequest;
use yaak_models::util::{BatchUpsertResult, ImportDestination, ImportPlan, UpdateSource};
use yaak_plugins::events::{
Color, ErrorResponse, FilterResponse, InternalEvent, InternalEventPayload, PluginContext,
@@ -330,6 +331,12 @@ async fn cmd_grpc_go<R: Runtime>(
let settings = app_handle.db().get_settings();
let client_cert = find_client_certificate(&request.url, &settings.client_certificates);
// Capture the stored request, not the rendered one: what a restore should
// put back is what the user typed
let version_id = app_handle
.db()
.snapshot_request_for_send(&AnyRequest::GrpcRequest(unrendered_request.clone()));
let conn = app_handle.db().upsert_grpc_connection(
&GrpcConnection {
workspace_id: request.workspace_id.clone(),
@@ -338,6 +345,7 @@ async fn cmd_grpc_go<R: Runtime>(
elapsed: 0,
state: GrpcConnectionState::Initialized,
url: request.url.clone(),
version_id,
..Default::default()
},
&UpdateSource::from_window_label(window.label()),
@@ -20,6 +20,7 @@ use yaak_models::models::{
HttpResponseHeader, WebsocketConnection, WebsocketConnectionState, WebsocketEvent,
WebsocketEventType,
};
use yaak_models::queries::any_request::AnyRequest;
use yaak_models::util::UpdateSource;
use yaak_plugins::events::{CallHttpAuthenticationRequest, HttpHeader, RenderPurpose};
use yaak_plugins::template_callback::PluginTemplateCallback;
@@ -169,10 +170,17 @@ pub async fn cmd_ws_connect<R: Runtime>(
)
.await?;
// Capture the stored request, not the rendered one: what a restore should
// put back is what the user typed
let version_id = app_handle
.db()
.snapshot_request_for_send(&AnyRequest::WebsocketRequest(unrendered_request.clone()));
let connection = app_handle.db().upsert_websocket_connection(
&WebsocketConnection {
workspace_id: request.workspace_id.clone(),
request_id: request_id.to_string(),
version_id,
..Default::default()
},
&UpdateSource::from_window_label(window.label()),