Route all app commands through a single RPC envelope (#542)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-08-14 14:16:14 -07:00
committed by GitHub
co-authored by Claude Fable 5
parent 1f91cddab9
commit 23e7229e63
37 changed files with 2473 additions and 395 deletions
@@ -1,10 +1,9 @@
import type { LicenseCheckStatus } from "@yaakapp-internal/license";
import { checkLicense } from "@yaakapp-internal/license";
import { useCallback, useEffect, useRef, useState } from "react";
import { useKeyValue } from "../hooks/useKeyValue";
import { appInfo } from "../lib/appInfo";
import { pricingUrl } from "../lib/pricingUrl";
import { DismissibleBanner } from "./core/DismissibleBanner";
import { rpc } from "../lib/rpc";
import { platform } from "@yaakapp-internal/platform";
const COMMERCIAL_USE_SNOOZE_MS = 7 * 24 * 60 * 60 * 1000;
@@ -95,7 +94,7 @@ async function shouldShowCommercialUsePrompt(): Promise<boolean> {
}
try {
const license = await rpc<LicenseCheckStatus>("plugin:yaak-license|check");
const license = await checkLicense();
return license.status === "personal_use";
} catch (err) {
console.log("Failed to check license before commercial-use prompt", err);
+8 -64
View File
@@ -1,73 +1,17 @@
import type { RpcPayload } from "@yaakapp-internal/platform";
import { platform } from "@yaakapp-internal/platform";
import type { RpcSchema } from "@yaakapp-internal/tauri-client";
/**
* Every backend command the client sends.
* Every backend command the app can call: the generated wire schema, one field
* per `RpcRouter` registration on the Rust side. A typo'd or unregistered
* command name is a compile error. Host plugin commands (license, fonts,
* mac-window) don't appear here — each lives behind its own package's facade.
*
* Listing them keeps typos out and gives us the inventory to check the Rust
* side against. Once the app's commands move onto `RpcRouter`, this union is
* replaced by the generated `RpcSchema` and the payload and result types come
* with it, the way `apps/yaak-proxy/lib/rpc.ts` already works.
* `RpcSchema` also carries each command's request and response payload types;
* adopting them at call sites is an incremental follow-up.
*/
type AppCmd =
| "cmd_call_grpc_request_action"
| "cmd_call_http_authentication_action"
| "cmd_call_http_request_action"
| "cmd_call_websocket_request_action"
| "cmd_call_workspace_action"
| "cmd_call_folder_action"
| "cmd_check_for_updates"
| "cmd_curl_to_request"
| "cmd_decrypt_template"
| "cmd_default_headers"
| "cmd_delete_all_grpc_connections"
| "cmd_delete_all_http_responses"
| "cmd_delete_send_history"
| "cmd_dismiss_notification"
| "cmd_export_data"
| "cmd_format_graphql"
| "cmd_format_json"
| "cmd_get_http_authentication_config"
| "cmd_get_http_authentication_summaries"
| "cmd_get_http_response_events"
| "cmd_get_sse_events"
| "cmd_get_themes"
| "cmd_get_workspace_meta"
| "cmd_git_add_credential"
| "cmd_git_clone"
| "cmd_grpc_go"
| "cmd_grpc_reflect"
| "cmd_grpc_request_actions"
| "cmd_http_request_actions"
| "cmd_websocket_request_actions"
| "cmd_workspace_actions"
| "cmd_folder_actions"
| "cmd_http_request_body"
| "cmd_http_response_body"
| "cmd_import_data"
| "cmd_metadata"
| "cmd_restart"
| "cmd_new_child_window"
| "cmd_new_main_window"
| "cmd_plugin_info"
| "cmd_plugin_init_errors"
| "cmd_reload_plugins"
| "cmd_render_template"
| "cmd_save_base64_to_binary"
| "cmd_save_response"
| "cmd_secure_template"
| "cmd_send_ephemeral_request"
| "cmd_send_feedback"
| "cmd_send_http_request"
| "cmd_template_function_summaries"
| "cmd_template_function_config"
| "cmd_template_tokens_to_string"
| "models_get_graphql_introspection"
| "models_get_settings"
| "models_grpc_events"
| "models_upsert_graphql_introspection"
| "models_websocket_events"
| "plugin:yaak-license|check";
type AppCmd = keyof RpcSchema;
/** Call a backend command. */
export function rpc<T>(cmd: AppCmd, payload?: RpcPayload): Promise<T> {