Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat(desktop): connection timeout bounds (#6524)

Shreyasda23974bed89
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json
index 1f52c2359..ad5439d0f 100644
--- a/packages/hoppscotch-common/locales/en.json
+++ b/packages/hoppscotch-common/locales/en.json
@@ -1301,7 +1301,8 @@
"delete_account": "Delete account",
"delete_account_description": "Once you delete your account, all your data will be permanently deleted. This action cannot be undone.",
"desktop": "Desktop",
- "desktop_description": "Update behavior, keyboard handling, and display preferences for the Hoppscotch desktop app.",
+ "desktop_connection": "Connection",
+ "desktop_description": "Update behavior, connection timeouts, keyboard handling, and display preferences for the Hoppscotch desktop app.",
"desktop_display": "Display",
"desktop_keyboard": "Keyboard",
"desktop_keyboard_strategy_label": "Match shortcuts by typed letter or physical position",
@@ -1316,6 +1317,10 @@
"disable_encode_mode_tooltip": "Never encode the parameters in the request",
"disable_update_checks": "Disable automatic update checks",
"disable_update_checks_description": "Skip the update check at app startup. Use the button above to check on demand.",
+ "connection_timeout": "Connection timeout",
+ "connection_timeout_description": "How long to wait for your instance to respond. Downloading an instance allows ten times this limit. Restart the app for a change to reach the download.",
+ "connection_timeout_seconds": "{seconds} seconds",
+ "connection_timeout_seconds_default": "{seconds} seconds (default)",
"zoom_level": "Zoom level",
"zoom_level_description": "Scales the entire interface. Higher values make text and controls larger on high-resolution screens.",
"zoom_level_100": "100%",
diff --git a/packages/hoppscotch-common/package.json b/packages/hoppscotch-common/package.json
index 65b30ae9f..aef1aa79c 100644
--- a/packages/hoppscotch-common/package.json
+++ b/packages/hoppscotch-common/package.json
@@ -40,7 +40,7 @@
"@hoppscotch/httpsnippet": "3.0.9",
"@hoppscotch/js-sandbox": "workspace:^",
"@hoppscotch/kernel": "workspace:^",
- "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#9d4528be4f385bccbe46859631d31aa2ee1ec0b6",
+ "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b",
"@hoppscotch/ui": "0.2.6",
"@hoppscotch/vue-toasted": "0.1.0",
"@lezer/highlight": "1.2.1",
diff --git a/packages/hoppscotch-common/src/components/settings/Desktop.vue b/packages/hoppscotch-common/src/components/settings/Desktop.vue
index d09a2b505..e8d870328 100644
--- a/packages/hoppscotch-common/src/components/settings/Desktop.vue
+++ b/packages/hoppscotch-common/src/components/settings/Desktop.vue
@@ -1,7 +1,7 @@
<template>
<!-- Three-column grid identical to the shared settings page's other
- sections (General / Theme / Kernel interceptor), so this block falls
- into the same visual rhythm when it renders. -->
+ sections (General / Theme / Kernel interceptor), so this section
+ aligns with them and declares no column widths of its own. -->
<div class="md:grid md:grid-cols-3 md:gap-4">
<div class="p-8 md:col-span-1">
<h3 class="heading">
@@ -17,14 +17,13 @@
{{ t("settings.desktop_updates") }}
</h4>
- <!-- Manual update check control. The button's label, icon,
- disabled-ness, and click behavior all come from one view
- descriptor computed from the update state, so adding or
- renaming a state means touching one `case` instead of five
- parallel switches. A fixed `min-width` holds the button
- size stable across label changes. Download progress rides
- inline in the label rather than in a separate progress bar,
- so the control stays the same size across every state. -->
+ <!-- The check button's label, icon, disabled-ness, and click
+ behavior all come from one view descriptor computed from the
+ update state, so adding or renaming a state means touching one
+ `case`. A fixed `min-width`
+ keeps the button size stable across label changes, and download
+ progress renders inline in the label so the control stays the
+ same size in every state. -->
<div class="mt-4">
<div class="flex items-center space-x-3">
<HoppButtonSecondary
@@ -51,11 +50,10 @@
</div>
</div>
- <!-- Auto-check toggle with its own description. The inner
- `flex items-center` wrapper matches the convention used by
- other toggles on the shared settings page (see
- `settings/Native.vue`), so the toggle sits at the same left
- edge as the check button above instead of stretching to fill
+ <!-- The inner `flex items-center` wrapper matches the convention
+ other toggles on the shared settings page use (see
+ `settings/Native.vue`), so the toggle aligns to the same left
+ edge as the check button above, so it does not stretch to fill
the `flex-col` parent. -->
<div class="mt-6">
<div class="flex items-center">
@@ -72,12 +70,66 @@
</div>
</section>
- <!-- Keyboard layout strategy. Three radios, each with a one-line
- description so the user can pick without trial and error.
- Selection writes to `keyboardLayoutStrategy` through the
- desktop settings composable, which mirrors it into the
- keyboard-strategy holder so the next keypress respects the
- change. -->
+ <!-- The stored value is a total request deadline, and the bundle
+ download client multiplies it by ten. The description states both
+ numbers because a user reading only the preset would expect a
+ 120s pick to abort a download at two minutes. Rust reads the
+ value once at startup, so the description also states the restart
+ requirement. FE-1188 replaces the single deadline with separate
+ connect, read, and total bounds. -->
+ <section>
+ <h4 class="font-semibold text-secondaryDark">
+ {{ t("settings.desktop_connection") }}
+ </h4>
+
+ <div class="mt-4">
+ <label class="text-secondaryLight">{{
+ t("settings.connection_timeout")
+ }}</label>
+ <div class="mt-3">
+ <tippy
+ interactive
+ trigger="click"
+ theme="popover"
+ :on-shown="() => timeoutTippyActions?.focus()"
+ >
+ <HoppSmartSelectWrapper>
+ <HoppButtonSecondary
+ class="!min-w-[15rem] !justify-start pr-8"
+ :label="selectedTimeoutLabel"
+ outline
+ />
+ </HoppSmartSelectWrapper>
+ <template #content="{ hide }">
+ <div
+ ref="timeoutTippyActions"
+ class="flex flex-col focus:outline-none"
+ tabindex="0"
+ @keyup.escape="hide()"
+ >
+ <HoppSmartItem
+ v-for="option in connectionTimeoutOptions"
+ :key="`timeout-${option.ms}`"
+ :label="option.label"
+ :info-icon="option.selected ? IconLucideCheck : null"
+ :active-info-icon="option.selected"
+ @click="() => selectConnectionTimeout(option.ms, hide)"
+ />
+ </div>
+ </template>
+ </tippy>
+ </div>
+ <p class="mt-3 text-xs text-secondaryLight">
+ {{ t("settings.connection_timeout_description") }}
+ </p>
+ </div>
+ </section>
+
+ <!-- Each radio has a one-line description so the user can pick
+ without trial and error. Selection writes to
+ `keyboardLayoutStrategy` through the desktop settings composable,
+ which mirrors it into the keyboard-strategy holder so the next
+ keypress respects the change. -->
<section>
<h4 class="font-semibold text-secondaryDark">
{{ t("settings.desktop_keyboard") }}
@@ -116,12 +168,10 @@
{{ t("settings.desktop_display") }}
</h4>
- <!-- Fixed-preset zoom control. Four named scale steps starting
- at 100% follow Apple's pattern across Display preferences
- and Safari View, which keeps every shipped zoom inside the
- range cross-platform QA covers. Sub-100% steps stay out of
- scope because the AppHeader's macOS traffic-light clearance
- sets a 100% floor (see FE-1261). -->
+ <!-- The steps start at 100% because the AppHeader's macOS
+ traffic-light clearance is hardcoded for an unscaled header, so
+ anything below 100% overlaps the traffic lights (see
+ FE-1261). -->
<div class="mt-4">
<label class="text-secondaryLight">{{
t("settings.zoom_level")
@@ -147,16 +197,22 @@
import { computed, onBeforeUnmount, ref, watch, type Component } from "vue"
import {
HoppButtonSecondary,
+ HoppSmartItem,
HoppSmartRadio,
HoppSmartRadioGroup,
+ HoppSmartSelectWrapper,
HoppSmartToggle,
} from "@hoppscotch/ui"
import { useI18n } from "~/composables/i18n"
-import type { DesktopSettings } from "~/platform/desktop-settings"
+import {
+ DESKTOP_SETTINGS_SCHEMA,
+ type DesktopSettings,
+} from "~/platform/desktop-settings"
import IconLucideDownload from "~icons/lucide/download"
import IconLucideRefreshCw from "~icons/lucide/refresh-cw"
import IconLucideLoader from "~icons/lucide/loader"
+import IconLucideCheck from "~icons/lucide/check"
import IconLucideCheckCircle from "~icons/lucide/check-circle"
import IconLucideAlertCircle from "~icons/lucide/alert-circle"
@@ -180,12 +236,11 @@ const t = useI18n()
const desktopSettings = useDesktopSettings()
const updateCheck = useUpdateCheck()
-// Composed view descriptor for the manual-check button. Every field the
-// template binds comes from the same function so adding, renaming, or
-// deleting an update state is a single-case edit. The alternative of
-// parallel computeds for `label`, `icon`, `disabled`, and click handler
-// spreads the behavior for each state across four functions and leaves
-// no single place to read what state X renders as.
+// Every field the template binds comes from the same function, so adding,
+// renaming, or deleting an update state is a single-case edit. Parallel
+// computeds for `label`, `icon`, `disabled`, and the click handler would
+// spread each state's behavior across four functions with no single place
+// to read what a given state renders as.
type ButtonView = {
label: string
icon: Component
@@ -343,10 +398,66 @@ async function toggleDisableUpdateChecks(): Promise<void> {
)
}
-// Keyboard layout strategy radios. Order is recommended-first so users
-// without a preference get the smart default. Labels and descriptions
-// are i18n keys, rebuilt as a `computed` so a locale change updates
-// the rendered text.
+// Milliseconds because the schema field, the Rust bridge, and the TS race
+// all read that unit, so nothing converts at a boundary. Array order is the
+// order the popup renders.
+const CONNECTION_TIMEOUT_PRESETS_MS = [30_000, 60_000, 90_000, 120_000]
+
+// Reading the default off the schema keeps the "(default)" marker
+// correct when `connectionTimeoutMs`'s default changes. A repeated
+// 30_000 here would leave the marker on the old preset.
+const DEFAULT_CONNECTION_TIMEOUT_MS = DESKTOP_SETTINGS_SCHEMA.parse(
+ {}
+).connectionTimeoutMs
+
+// Labels derive from the stored value, so a store holding something
+// off-preset (hand edited, or written by a schema that widens the range)
+// shows the timeout actually in effect.
+const timeoutLabel = (ms: number): string => {
+ const seconds = Math.round(ms / 1000)
+ return ms === DEFAULT_CONNECTION_TIMEOUT_MS
+ ? t("settings.connection_timeout_seconds_default", { seconds })
+ : t("settings.connection_timeout_seconds", { seconds })
+}
+
+const connectionTimeoutOptions = computed(() =>
+ CONNECTION_TIMEOUT_PRESETS_MS.map((ms) => ({
+ ms,
+ label: timeoutLabel(ms),
+ selected: desktopSettings.settings.connectionTimeoutMs === ms,
+ }))
+)
+
+const selectedTimeoutLabel = computed(() =>
+ timeoutLabel(desktopSettings.settings.connectionTimeoutMs)
+)
+
+// Tippy focuses this element on open so Escape closes the popup, the same
+// wiring `smart/ChangeLanguage.vue` uses.
+const timeoutTippyActions = ref<HTMLElement | null>(null)
+
+// The popup item calls this from a click handler that discards the returned
+// promise, so a rejection would escape as an unhandled rejection Vue cannot
+// route to its error handler. `update()` already logs the failure and rolls
+// the reactive value back, so the catch here only stops the rethrow from
+// leaving the handler. `close` runs in `finally` so the popup shuts whether
+// the write succeeds or fails.
+async function selectConnectionTimeout(
+ ms: number,
+ close: () => void
+): Promise<void> {
+ try {
+ await desktopSettings.update("connectionTimeoutMs", ms)
+ } catch {
+ // handled in the composable
+ } finally {
+ close()
+ }
+}
+
+// Order is recommended-first so users without a preference get the smart
+// default. Labels and descriptions are i18n keys, rebuilt as a `computed`
+// so a locale change updates the rendered text.
type KeyboardStrategy = DesktopSettings["keyboardLayoutStrategy"]
const keyboardStrategyOptions = computed<
@@ -373,12 +484,10 @@ async function setKeyboardStrategy(value: KeyboardStrategy): Promise<void> {
await desktopSettings.update("keyboardLayoutStrategy", value)
}
-// Zoom presets as `{ value, label }` pairs, in the order the control
-// renders. `value` is the string id the radio group emits, kept distinct
-// from the stored float so the radio's `model-value` comparison never
-// trips on float equality. The float-to-string mapping lives in one
-// place (`zoomPresets`) and gets inverted by `setZoomPreset()` when the
-// user picks an option.
+// `value` is the string id the radio group emits, kept distinct from the
+// stored float so the radio's `model-value` comparison never trips on float
+// equality. The float-to-string mapping stays in `zoomPresets` alone and
+// `setZoomPreset()` inverts it when the user picks an option.
const zoomPresets = computed(() => [
{ value: "1.0", label: t("settings.zoom_level_100") },
{ value: "1.1", label: t("settings.zoom_level_110") },
diff --git a/packages/hoppscotch-desktop/package.json b/packages/hoppscotch-desktop/package.json
index 2e3af6673..938b7c086 100644
--- a/packages/hoppscotch-desktop/package.json
+++ b/packages/hoppscotch-desktop/package.json
@@ -27,7 +27,7 @@
"@fontsource-variable/roboto-mono": "5.2.9",
"@hoppscotch/common": "workspace:^",
"@hoppscotch/kernel": "workspace:^",
- "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#9d4528be4f385bccbe46859631d31aa2ee1ec0b6",
+ "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b",
"@hoppscotch/ui": "0.2.6",
"@tauri-apps/api": "2.1.1",
"@tauri-apps/plugin-fs": "2.0.2",
diff --git a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/pnpm-lock.yaml b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/pnpm-lock.yaml
index 5cf884868..4da6da3eb 100644
--- a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/pnpm-lock.yaml
+++ b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/pnpm-lock.yaml
@@ -14,10 +14,10 @@ importers:
devDependencies:
'@rollup/plugin-typescript':
specifier: ^12.3.0
rollup:
- specifier: ^4.54.0
- version: 4.54.0
+ specifier: ^4.59.0
+ version: 4.62.2
tslib:
specifier: ^2.8.1
version: 2.8.1
@@ -49,113 +49,141 @@ packages:
rollup:
optional: true
- '@rollup/[email protected]':
- resolution: {integrity: sha512-OywsdRHrFvCdvsewAInDKCNyR3laPA2mc9bRYJ6LBp5IyvF3fvXbbNR0bSzHlZVFtn6E0xw2oZlyjg4rKCVcng==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==}
cpu: [arm]
os: [android]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-Skx39Uv+u7H224Af+bDgNinitlmHyQX1K/atIA32JP3JQw6hVODX5tkbi2zof/E69M1qH2UoN3Xdxgs90mmNYw==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==}
cpu: [arm64]
os: [android]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-k43D4qta/+6Fq+nCDhhv9yP2HdeKeP56QrUUTW7E6PhZP1US6NDqpJj4MY0jBHlJivVJD5P8NxrjuobZBJTCRw==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==}
cpu: [arm64]
os: [darwin]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-cOo7biqwkpawslEfox5Vs8/qj83M/aZCSSNIWpVzfU2CYHa2G3P1UN5WF01RdTHSgCkri7XOlTdtk17BezlV3A==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==}
cpu: [x64]
os: [darwin]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-miSvuFkmvFbgJ1BevMa4CPCFt5MPGw094knM64W9I0giUIMMmRYcGW/JWZDriaw/k1kOBtsWh1z6nIFV1vPNtA==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==}
cpu: [arm64]
os: [freebsd]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-KGXIs55+b/ZfZsq9aR026tmr/+7tq6VG6MsnrvF4H8VhwflTIuYh+LFUlIsRdQSgrgmtM3fVATzEAj4hBQlaqQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==}
cpu: [x64]
os: [freebsd]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-EHMUcDwhtdRGlXZsGSIuXSYwD5kOT9NVnx9sqzYiwAc91wfYOE1g1djOEDseZJKKqtHAHGwnGPQu3kytmfaXLQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==}
cpu: [arm]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-+pBrqEjaakN2ySv5RVrj/qLytYhPKEUwk+e3SFU5jTLHIcAtqh2rLrd/OkbNuHJpsBgxsD8ccJt5ga/SeG0JmA==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==}
cpu: [arm]
os: [linux]
+ libc: [musl]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-NSqc7rE9wuUaRBsBp5ckQ5CVz5aIRKCwsoa6WMF7G01sX3/qHUw/z4pv+D+ahL1EIKy6Enpcnz1RY8pf7bjwng==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==}
cpu: [arm64]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-gr5vDbg3Bakga5kbdpqx81m2n9IX8M6gIMlQQIXiLTNeQW6CucvuInJ91EuCJ/JYvc+rcLLsDFcfAD1K7fMofg==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==}
cpu: [arm64]
os: [linux]
+ libc: [musl]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-gsrtB1NA3ZYj2vq0Rzkylo9ylCtW/PhpLEivlgWe0bpgtX5+9j9EZa0wtZiCjgu6zmSeZWyI/e2YRX1URozpIw==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==}
cpu: [loong64]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-y3qNOfTBStmFNq+t4s7Tmc9hW2ENtPg8FeUD/VShI7rKxNW7O4fFeaYbMsd3tpFlIg1Q8IapFgy7Q9i2BqeBvA==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==}
+ cpu: [loong64]
+ os: [linux]
+ libc: [musl]
+
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==}
cpu: [ppc64]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-89sepv7h2lIVPsFma8iwmccN7Yjjtgz0Rj/Ou6fEqg3HDhpCa+Et+YSufy27i6b0Wav69Qv4WBNl3Rs6pwhebQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==}
+ cpu: [ppc64]
+ os: [linux]
+ libc: [musl]
+
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==}
cpu: [riscv64]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-ZcU77ieh0M2Q8Ur7D5X7KvK+UxbXeDHwiOt/CPSBTI1fBmeDMivW0dPkdqkT4rOgDjrDDBUed9x4EgraIKoR2A==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==}
cpu: [riscv64]
os: [linux]
+ libc: [musl]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-2AdWy5RdDF5+4YfG/YesGDDtbyJlC9LHmL6rZw6FurBJ5n4vFGupsOBGfwMRjBYH7qRQowT8D/U4LoSvVwOhSQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==}
cpu: [s390x]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-WGt5J8Ij/rvyqpFexxk3ffKqqbLf9AqrTBbWDk7ApGUzaIs6V+s2s84kAxklFwmMF/vBNGrVdYgbblCOFFezMQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==}
cpu: [x64]
os: [linux]
+ libc: [glibc]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-JzQmb38ATzHjxlPHuTH6tE7ojnMKM2kYNzt44LO/jJi8BpceEC8QuXYA908n8r3CNuG/B3BV8VR3Hi1rYtmPiw==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==}
cpu: [x64]
os: [linux]
+ libc: [musl]
+
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==}
+ cpu: [x64]
+ os: [openbsd]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-huT3fd0iC7jigGh7n3q/+lfPcXxBi+om/Rs3yiFxjvSxbSB6aohDFXbWvlspaqjeOh+hx7DDHS+5Es5qRkWkZg==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==}
cpu: [arm64]
os: [openharmony]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-c2V0W1bsKIKfbLMBu/WGBz6Yci8nJ/ZJdheE0EwB73N3MvHYKiKGs3mVilX4Gs70eGeDaMqEob25Tw2Gb9Nqyw==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==}
cpu: [arm64]
os: [win32]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-woEHgqQqDCkAzrDhvDipnSirm5vxUXtSKDYTVpZG3nUdW/VVB5VdCYA2iReSj/u3yCZzXID4kuKG7OynPnB3WQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==}
cpu: [ia32]
os: [win32]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-dzAc53LOuFvHwbCEOS0rPbXp6SIhAf2txMP5p6mGyOXXw5mWY8NGGbPMPrs4P1WItkfApDathBj/NzMLUZ9rtQ==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==}
cpu: [x64]
os: [win32]
- '@rollup/[email protected]':
- resolution: {integrity: sha512-hYT5d3YNdSh3mbCU1gwQyPgQd3T2ne0A3KG8KSBdav5TiBg6eInVmV+TeR5uHufiIgSFg0XsOWGW5/RhNcSvPg==}
+ '@rollup/[email protected]':
+ resolution: {integrity: sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==}
cpu: [x64]
os: [win32]
@@ -165,6 +193,9 @@ packages:
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
+ '@types/[email protected]':
+ resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
+
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
@@ -196,8 +227,8 @@ packages:
engines: {node: '>= 0.4'}
hasBin: true
- resolution: {integrity: sha512-3nk8Y3a9Ea8szgKhinMlGMhGMw89mqule3KWczxhIzqudyHdCIOHw8WJlj/r329fACjKLEh13ZSk7oE22kyeIw==}
+ resolution: {integrity: sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
hasBin: true
@@ -215,93 +246,104 @@ packages:
snapshots:
dependencies:
- '@rollup/pluginutils': 5.3.0([email protected])
+ '@rollup/pluginutils': 5.3.0([email protected])
resolve: 1.22.11
typescript: 5.9.3
optionalDependencies:
- rollup: 4.54.0
+ rollup: 4.62.2
tslib: 2.8.1
dependencies:
'@types/estree': 1.0.8
estree-walker: 2.0.2
picomatch: 4.0.3
optionalDependencies:
- rollup: 4.54.0
+ rollup: 4.62.2
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
optional: true
- '@rollup/[email protected]':
+ '@rollup/[email protected]':
+ optional: true
+
+ '@rollup/[email protected]':
+ optional: true
+
+ '@rollup/[email protected]':
+ optional: true
+
+ '@rollup/[email protected]':
optional: true
'@tauri-apps/[email protected]': {}
'@types/[email protected]': {}
+ '@types/[email protected]': {}
+
@@ -327,32 +369,35 @@ snapshots:
path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0
dependencies:
- '@types/estree': 1.0.8
+ '@types/estree': 1.0.9
optionalDependencies:
- '@rollup/rollup-android-arm-eabi': 4.54.0
- '@rollup/rollup-android-arm64': 4.54.0
- '@rollup/rollup-darwin-arm64': 4.54.0
- '@rollup/rollup-darwin-x64': 4.54.0
- '@rollup/rollup-freebsd-arm64': 4.54.0
- '@rollup/rollup-freebsd-x64': 4.54.0
- '@rollup/rollup-linux-arm-gnueabihf': 4.54.0
- '@rollup/rollup-linux-arm-musleabihf': 4.54.0
- '@rollup/rollup-linux-arm64-gnu': 4.54.0
- '@rollup/rollup-linux-arm64-musl': 4.54.0
- '@rollup/rollup-linux-loong64-gnu': 4.54.0
- '@rollup/rollup-linux-ppc64-gnu': 4.54.0
- '@rollup/rollup-linux-riscv64-gnu': 4.54.0
- '@rollup/rollup-linux-riscv64-musl': 4.54.0
- '@rollup/rollup-linux-s390x-gnu': 4.54.0
- '@rollup/rollup-linux-x64-gnu': 4.54.0
- '@rollup/rollup-linux-x64-musl': 4.54.0
- '@rollup/rollup-openharmony-arm64': 4.54.0
- '@rollup/rollup-win32-arm64-msvc': 4.54.0
- '@rollup/rollup-win32-ia32-msvc': 4.54.0
- '@rollup/rollup-win32-x64-gnu': 4.54.0
- '@rollup/rollup-win32-x64-msvc': 4.54.0
+ '@rollup/rollup-android-arm-eabi': 4.62.2
+ '@rollup/rollup-android-arm64': 4.62.2
+ '@rollup/rollup-darwin-arm64': 4.62.2
+ '@rollup/rollup-darwin-x64': 4.62.2
+ '@rollup/rollup-freebsd-arm64': 4.62.2
+ '@rollup/rollup-freebsd-x64': 4.62.2
+ '@rollup/rollup-linux-arm-gnueabihf': 4.62.2
+ '@rollup/rollup-linux-arm-musleabihf': 4.62.2
+ '@rollup/rollup-linux-arm64-gnu': 4.62.2
+ '@rollup/rollup-linux-arm64-musl': 4.62.2
+ '@rollup/rollup-linux-loong64-gnu': 4.62.2
+ '@rollup/rollup-linux-loong64-musl': 4.62.2
+ '@rollup/rollup-linux-ppc64-gnu': 4.62.2
+ '@rollup/rollup-linux-ppc64-musl': 4.62.2
+ '@rollup/rollup-linux-riscv64-gnu': 4.62.2
+ '@rollup/rollup-linux-riscv64-musl': 4.62.2
+ '@rollup/rollup-linux-s390x-gnu': 4.62.2
+ '@rollup/rollup-linux-x64-gnu': 4.62.2
+ '@rollup/rollup-linux-x64-musl': 4.62.2
+ '@rollup/rollup-openbsd-x64': 4.62.2
+ '@rollup/rollup-openharmony-arm64': 4.62.2
+ '@rollup/rollup-win32-arm64-msvc': 4.62.2
+ '@rollup/rollup-win32-ia32-msvc': 4.62.2
+ '@rollup/rollup-win32-x64-gnu': 4.62.2
+ '@rollup/rollup-win32-x64-msvc': 4.62.2
fsevents: 2.3.3
diff --git a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/api/client.rs b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/api/client.rs
index f95ec3ba9..8c9170f42 100644
--- a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/api/client.rs
+++ b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/api/client.rs
@@ -11,37 +11,54 @@ use super::{
API_VERSION,
};
-const DEFAULT_TIMEOUT: Duration = Duration::from_secs(30);
-
+// A bundle download transfers several orders of magnitude more bytes than a
+// manifest or key request, so its client gets this multiple of the
+// configured timeout.
+const DOWNLOAD_TIMEOUT_FACTOR: u32 = 10;
+
+/// HTTP client for one instance server, built with the timeout the host
+/// configured through `ApiConfig`.
+///
+/// The `timeout` field is kept after the client is built because
+/// `download_bundle` constructs a second client with its own allowance, and
+/// reqwest bakes timeouts in at build time with no way to read one back off
+/// a built `Client`.
#[derive(Debug, Clone)]
pub struct ApiClient {
client: HttpClient,
base_url: Url,
+ timeout: Duration,
}
impl ApiClient {
- pub fn new(base_url: impl AsRef<str>) -> Result<Self> {
+ pub fn new(base_url: impl AsRef<str>, timeout: Duration) -> Result<Self> {
tracing::info!(
- "Initializing ApiClient with base URL: {}",
- base_url.as_ref()
+ base_url = base_url.as_ref(),
+ ?timeout,
+ "Initializing ApiClient"
);
let client = HttpClient::builder()
- .timeout(DEFAULT_TIMEOUT)
- .user_agent(format!(
- "{}/{}",
- env!("CARGO_PKG_NAME"),
- env!("CARGO_PKG_VERSION")
- ))
+ .timeout(timeout)
+ .user_agent(Self::user_agent())
.build()
.map_err(ApiError::RequestFailed)?;
Ok(Self {
client,
base_url: base_url.as_ref().parse().map_err(ApiError::InvalidUrl)?,
+ timeout,
})
}
+ fn user_agent() -> String {
+ format!(
+ "{}/{}",
+ env!("CARGO_PKG_NAME"),
+ env!("CARGO_PKG_VERSION")
+ )
+ }
+
pub async fn list_key(&self) -> Result<PublicKeyInfo> {
self.get(&format!("/api/{API_VERSION}/key")).await
}
@@ -59,12 +76,8 @@ impl ApiClient {
let url = self.build_url(&format!("/api/{API_VERSION}/bundle"))?;
let download_client = HttpClient::builder()
- .timeout(10 * DEFAULT_TIMEOUT)
- .user_agent(format!(
- "{}/{}",
- env!("CARGO_PKG_NAME"),
- env!("CARGO_PKG_VERSION")
- ))
+ .timeout(DOWNLOAD_TIMEOUT_FACTOR * self.timeout)
+ .user_agent(Self::user_agent())
.build()
.map_err(ApiError::RequestFailed)?;
diff --git a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/bundle/loader.rs b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/bundle/loader.rs
index 30b4c2550..7430478d9 100644
--- a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/bundle/loader.rs
+++ b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/bundle/loader.rs
@@ -1,4 +1,4 @@
-use std::sync::Arc;
+use std::{sync::Arc, time::Duration};
use super::{BundleError, Result, VerifiedBundle};
use crate::{
@@ -14,14 +14,28 @@ struct BundleInfo {
content: Vec<u8>,
}
+/// Downloads, verifies, and caches bundles for instance servers.
+///
+/// The `api_timeout` field holds the value every `ApiClient` this loader
+/// creates is built with. Those clients are per-server and short-lived, so
+/// the timeout has to outlive any one of them.
pub struct BundleLoader {
cache: Arc<CacheManager>,
storage: Arc<StorageManager>,
+ api_timeout: Duration,
}
impl BundleLoader {
- pub fn new(cache: Arc<CacheManager>, storage: Arc<StorageManager>) -> Self {
- Self { cache, storage }
+ pub fn new(
+ cache: Arc<CacheManager>,
+ storage: Arc<StorageManager>,
+ api_timeout: Duration,
+ ) -> Self {
+ Self {
+ cache,
+ storage,
+ api_timeout,
+ }
}
pub async fn load_bundle(&self, server_url: &str) -> Result<()> {
@@ -101,10 +115,12 @@ impl BundleLoader {
}
fn create_api_client(&self, server_url: &str) -> Result<ApiClient> {
- Ok(ApiClient::new(server_url).map_err(|e| {
- tracing::error!(%server_url, %e, "Failed to create API client");
- e
- })?)
+ Ok(
+ ApiClient::new(server_url, self.api_timeout).map_err(|e| {
+ tracing::error!(%server_url, %e, "Failed to create API client");
+ e
+ })?,
+ )
}
async fn init_bundle_verifier(&self, api_client: &ApiClient) -> Result<BundleVerifier> {
diff --git a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/lib.rs b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/lib.rs
index 20a333e67..324caa606 100644
--- a/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/lib.rs
+++ b/packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-appload/src/lib.rs
@@ -106,7 +106,11 @@ pub fn init<R: Runtime>(config: Config) -> TauriPlugin<R> {
));
tracing::debug!("Setting up bundle loader.");
- let bundle_loader = Arc::new(bundle::BundleLoader::new(cache.clone(), storage.clone()));
+ let bundle_loader = Arc::new(bundle::BundleLoader::new(
+ cache.clone(),
+ storage.clone(),
+ config.api.timeout,
+ ));
tracing::debug!("Initializing host mapper.");
let host_mapper = Arc::new(mapping::HostMapper::new());
diff --git a/packages/hoppscotch-desktop/src-tauri/Cargo.lock b/packages/hoppscotch-desktop/src-tauri/Cargo.lock
index 9cc884f6d..ab3b995af 100644
--- a/packages/hoppscotch-desktop/src-tauri/Cargo.lock
+++ b/packages/hoppscotch-desktop/src-tauri/Cargo.lock
@@ -5567,7 +5567,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-appload"
version = "0.1.0"
-source = "git+https://github.com/CuriousCorrelation/tauri-plugin-appload?rev=9d4528be4f385bccbe46859631d31aa2ee1ec0b6#9d4528be4f385bccbe46859631d31aa2ee1ec0b6"
+source = "git+https://github.com/CuriousCorrelation/tauri-plugin-appload?rev=95eb43e6036b34a1ddcf4c4deb941b198aa02e4b#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b"
dependencies = [
"base64 0.22.1",
"blake3",
diff --git a/packages/hoppscotch-desktop/src-tauri/Cargo.toml b/packages/hoppscotch-desktop/src-tauri/Cargo.toml
index ebc5831b9..b20358089 100644
--- a/packages/hoppscotch-desktop/src-tauri/Cargo.toml
+++ b/packages/hoppscotch-desktop/src-tauri/Cargo.toml
@@ -29,7 +29,7 @@ tauri-plugin-store = "2.2.0"
tauri-plugin-dialog = "2.2.0"
tauri-plugin-fs = "2.2.0"
tauri-plugin-deep-link = "2.2.0"
-tauri-plugin-appload = { git = "https://github.com/CuriousCorrelation/tauri-plugin-appload", rev = "9d4528be4f385bccbe46859631d31aa2ee1ec0b6" }
+tauri-plugin-appload = { git = "https://github.com/CuriousCorrelation/tauri-plugin-appload", rev = "95eb43e6036b34a1ddcf4c4deb941b198aa02e4b" }
tauri-plugin-relay = { git = "https://github.com/CuriousCorrelation/tauri-plugin-relay", rev = "273488c8f50a22ee707af6b50ccd5570851f8bc9" }
axum = "0.8.1"
tower-http = { version = "0.6.2", features = ["cors"] }
diff --git a/packages/hoppscotch-desktop/src-tauri/src/config.rs b/packages/hoppscotch-desktop/src-tauri/src/config.rs
index c3b7aa486..8cece2cff 100644
--- a/packages/hoppscotch-desktop/src-tauri/src/config.rs
+++ b/packages/hoppscotch-desktop/src-tauri/src/config.rs
@@ -5,11 +5,10 @@ use tauri_plugin_appload::{ApiConfig, CacheConfig, Config, StorageConfig, Vendor
use crate::{error::HoppError, path};
-// Appload plugin configuration. These constants are baked into the plugin
-// config at startup via `HoppApploadConfig::build()`, before the webview
-// exists, so they cannot be overridden by runtime user settings. A future
-// user-facing connection timeout override will need a separate mechanism,
-// either a startup-time store file read or a deferred appload init.
+// Appload plugin configuration, baked into the plugin config at startup by
+// `HoppApploadConfig::build()`. `API_TIMEOUT_SECS` is the fallback when the
+// store holds no usable `connectionTimeoutMs`, see
+// `persisted_connection_timeout()`. The rest stay compile-time only.
const API_SERVER_URL: &str = "http://localhost:3200";
const API_TIMEOUT_SECS: u64 = 30;
const CACHE_MAX_SIZE_MB: usize = 1000;
@@ -17,6 +16,16 @@ const CACHE_FILE_TTL_SECS: u64 = 3600;
const CACHE_HOT_RATIO: f32 = 0.9;
const MAX_BUNDLE_SIZE_MB: usize = 50;
+// `STORE_FILE_NAME` mirrors `STORE_PATH` in the shell's `kernel/store.ts`,
+// and the namespace and key mirror `DESKTOP_SETTINGS_STORE_NAMESPACE` and
+// `DESKTOP_SETTINGS_STORE_KEY` in
+// `hoppscotch-common/src/platform/desktop-settings.ts`. A rename on either
+// side without a matching edit here reads as "no stored value" and silently
+// falls back, so the three constants stay next to the read that uses them.
+const STORE_FILE_NAME: &str = "hoppscotch-unified.store";
+const DESKTOP_SETTINGS_NAMESPACE: &str = "hoppscotch-desktop.v1";
+const DESKTOP_SETTINGS_KEY: &str = "desktopSettings";
+
pub struct HoppApploadConfig {
bundle_path: PathBuf,
manifest_path: PathBuf,
@@ -50,7 +59,8 @@ impl HoppApploadConfig {
Config::builder()
.api(ApiConfig {
server_url: API_SERVER_URL.to_string(),
- timeout: Duration::from_secs(API_TIMEOUT_SECS),
+ timeout: persisted_connection_timeout()
+ .unwrap_or_else(|| Duration::from_secs(API_TIMEOUT_SECS)),
})
.cache(CacheConfig {
max_size: CACHE_MAX_SIZE_MB * 1024 * 1024,
@@ -72,18 +82,65 @@ impl HoppApploadConfig {
}
}
-// Webview-pushed runtime settings bridge.
-//
+/// Extracts `connectionTimeoutMs` out of a parsed unified-store document.
+///
+/// The nesting comes from `TauriStoreManager` in
+/// `hoppscotch-kernel/src/store/impl/desktop/v/1.ts`, which keeps every
+/// namespace under a single `data` key on the tauri-plugin-store file and
+/// wraps each stored value in a `{ schemaVersion, metadata, data }`
+/// envelope, so the field is four levels down.
+///
+/// A zero or absent value returns `None`. Zero would build a client that
+/// times out before it can connect, and the Zod schema on the webview side
+/// already rejects it, so it only appears in a hand-edited or truncated
+/// file. No upper bound is applied, since a large value only costs a long
+/// wait the user asked for.
+fn connection_timeout_from_store(root: &serde_json::Value) -> Option<Duration> {
+ let ms = root
+ .get("data")?
+ .get(DESKTOP_SETTINGS_NAMESPACE)?
+ .get(DESKTOP_SETTINGS_KEY)?
+ .get("data")?
+ .get("connectionTimeoutMs")?
+ .as_u64()?;
+
+ (ms > 0).then(|| Duration::from_millis(ms))
+}
+
+/// Reads the persisted connection timeout directly off the store file.
+///
+/// `build()` is called before `tauri::Builder`, so there is no app handle
+/// and `tauri-plugin-store` is not registered yet, which rules out the
+/// plugin's own API. The webview's `set_desktop_config` push arrives later
+/// still, after appload has already downloaded the bundle it needed the
+/// timeout for, so a mailbox read here would see `None` on every launch and
+/// the first connection attempt would always use the compile-time default.
+///
+/// Every failure path returns `None` and leaves the caller on that default,
+/// so a fresh install, a missing directory, unreadable bytes, or a changed
+/// store layout all degrade to current behavior and startup continues.
+fn persisted_connection_timeout() -> Option<Duration> {
+ let path = path::store_dir().ok()?.join(STORE_FILE_NAME);
+ let contents = fs::read_to_string(&path).ok()?;
+ let root = serde_json::from_str::<serde_json::Value>(&contents).ok()?;
+ let timeout = connection_timeout_from_store(&root)?;
+
+ tracing::debug!(?timeout, "Applying persisted connection timeout");
+ Some(timeout)
+}
+
// The webview persists user settings (timeout, zoom, auto-reconnect, and so
-// on) via `tauri-plugin-store`. The Tauri shell needs live access to some
-// of those values, for example `connectionTimeoutMs` for the appload HTTP
-// client. Rather than having Rust read the store file directly, which would
-// couple this code to the plugin's on-disk format, the webview pushes the
-// current settings to Rust via `set_desktop_config` at init and on change.
+// on) via `tauri-plugin-store`, and pushes them to Rust through
+// `set_desktop_config` at init and on every change. A pushed value reaches
+// Rust without a restart, which is what a live consumer needs and what
+// reading the store file cannot give.
//
// The IPC plumbing is wired end-to-end but no Rust code reads
-// `DESKTOP_CONFIG` yet. Consumers such as the appload connection timeout
-// are future scope.
+// `DESKTOP_CONFIG` yet. The appload connection timeout deliberately does
+// not, because appload's config is built before any webview exists to push,
+// so `persisted_connection_timeout()` reads the store file for that one
+// value and accepts a restart to pick up a change. Anything needing the
+// change to apply immediately is what the mailbox is still here for.
//
// The struct deliberately only deserializes fields Rust actually consumes.
// TS sends the full `DESKTOP_SETTINGS_SCHEMA` payload and serde drops the
@@ -218,6 +275,65 @@ mod tests {
);
}
+ // Mirrors a real `hoppscotch-unified.store` document, including the
+ // sibling namespace and the sibling keys the shell writes. A minimal
+ // stub would pass even with the lookup path wrong by one level, so
+ // the full nesting is what makes the assertion meaningful.
+ fn store_document(settings: serde_json::Value) -> serde_json::Value {
+ serde_json::json!({
+ "data": {
+ "migration.v1": { "schema_version": { "data": 2 } },
+ "hoppscotch-desktop.v1": {
+ "connectionState": { "data": { "status": "idle" } },
+ "schema_version": { "data": 2 },
+ "desktopSettings": {
+ "schemaVersion": 1,
+ "metadata": { "namespace": "hoppscotch-desktop.v1" },
+ "data": settings
+ }
+ }
+ }
+ })
+ }
+
+ #[test]
+ fn reads_connection_timeout_from_store_document() {
+ let doc = store_document(serde_json::json!({
+ "connectionTimeoutMs": 90_000,
+ "zoomLevel": 1.0,
+ "keyboardLayoutStrategy": "hybrid"
+ }));
+ assert_eq!(
+ connection_timeout_from_store(&doc),
+ Some(Duration::from_millis(90_000))
+ );
+ }
+
+ #[test]
+ fn store_without_desktop_settings_yields_no_override() {
+ let empty = serde_json::json!({});
+ assert_eq!(connection_timeout_from_store(&empty), None);
+
+ let other_namespace = serde_json::json!({ "data": { "migration.v1": {} } });
+ assert_eq!(connection_timeout_from_store(&other_namespace), None);
+ }
+
+ #[test]
+ fn unusable_timeout_values_yield_no_override() {
+ // Zero would build a client that expires before it can connect.
+ let zero = store_document(serde_json::json!({ "connectionTimeoutMs": 0 }));
+ assert_eq!(connection_timeout_from_store(&zero), None);
+
+ let missing = store_document(serde_json::json!({ "zoomLevel": 1.0 }));
+ assert_eq!(connection_timeout_from_store(&missing), None);
+
+ let wrong_type = store_document(serde_json::json!({ "connectionTimeoutMs": "90s" }));
+ assert_eq!(connection_timeout_from_store(&wrong_type), None);
+
+ let negative = store_document(serde_json::json!({ "connectionTimeoutMs": -1 }));
+ assert_eq!(connection_timeout_from_store(&negative), None);
+ }
+
#[test]
fn desktop_config_deserializes_from_camel_case() {
let json = r#"{"connectionTimeoutMs": 60000}"#;
diff --git a/packages/hoppscotch-selfhost-web/package.json b/packages/hoppscotch-selfhost-web/package.json
index 12ad85c33..3cdd6507c 100644
--- a/packages/hoppscotch-selfhost-web/package.json
+++ b/packages/hoppscotch-selfhost-web/package.json
@@ -29,7 +29,7 @@
"@hoppscotch/common": "workspace:^",
"@hoppscotch/data": "workspace:^",
"@hoppscotch/kernel": "workspace:^",
- "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#9d4528be4f385bccbe46859631d31aa2ee1ec0b6",
+ "@hoppscotch/plugin-appload": "github:CuriousCorrelation/tauri-plugin-appload#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b",
"@hoppscotch/ui": "0.2.6",
"@import-meta-env/unplugin": "0.6.3",
"@tauri-apps/api": "2.1.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 084d8cbcf..6799718a0 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -563,8 +563,8 @@ importers:
specifier: workspace:^
version: link:../hoppscotch-kernel
'@hoppscotch/plugin-appload':
- specifier: github:CuriousCorrelation/tauri-plugin-appload#9d4528be4f385bccbe46859631d31aa2ee1ec0b6
- version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/9d4528be4f385bccbe46859631d31aa2ee1ec0b6'
+ specifier: github:CuriousCorrelation/tauri-plugin-appload#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b
+ version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/95eb43e6036b34a1ddcf4c4deb941b198aa02e4b'
'@hoppscotch/ui':
specifier: 0.2.6
@@ -1060,8 +1060,8 @@ importers:
specifier: workspace:^
version: link:../hoppscotch-kernel
'@hoppscotch/plugin-appload':
- specifier: github:CuriousCorrelation/tauri-plugin-appload#9d4528be4f385bccbe46859631d31aa2ee1ec0b6
- version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/9d4528be4f385bccbe46859631d31aa2ee1ec0b6'
+ specifier: github:CuriousCorrelation/tauri-plugin-appload#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b
+ version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/95eb43e6036b34a1ddcf4c4deb941b198aa02e4b'
'@hoppscotch/ui':
specifier: 0.2.6
@@ -1402,8 +1402,8 @@ importers:
specifier: workspace:^
version: link:../hoppscotch-kernel
'@hoppscotch/plugin-appload':
- specifier: github:CuriousCorrelation/tauri-plugin-appload#9d4528be4f385bccbe46859631d31aa2ee1ec0b6
- version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/9d4528be4f385bccbe46859631d31aa2ee1ec0b6'
+ specifier: github:CuriousCorrelation/tauri-plugin-appload#95eb43e6036b34a1ddcf4c4deb941b198aa02e4b
+ version: '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/95eb43e6036b34a1ddcf4c4deb941b198aa02e4b'
'@hoppscotch/ui':
specifier: 0.2.6
@@ -1777,8 +1777,8 @@ packages:
graphql:
optional: true
- '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/9d4528be4f385bccbe46859631d31aa2ee1ec0b6':
- resolution: {gitHosted: true, tarball: https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/9d4528be4f385bccbe46859631d31aa2ee1ec0b6}
+ '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/95eb43e6036b34a1ddcf4c4deb941b198aa02e4b':
+ resolution: {gitHosted: true, integrity: sha512-+sJ6tTM8TqpckwwSorde2X5xGvcJdFuzWex/nFRPvNB8CFPdhWXboLmNA9B6gUY69PkLZCmRKO596+A1kDBdkQ==, tarball: https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/95eb43e6036b34a1ddcf4c4deb941b198aa02e4b}
version: 0.1.0
'@CuriousCorrelation/plugin-relay@https://codeload.github.com/CuriousCorrelation/tauri-plugin-relay/tar.gz/273488c8f50a22ee707af6b50ccd5570851f8bc9':
@@ -14010,7 +14010,7 @@ snapshots:
optionalDependencies:
graphql: 16.14.0
- '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/9d4528be4f385bccbe46859631d31aa2ee1ec0b6':
+ '@CuriousCorrelation/plugin-appload@https://codeload.github.com/CuriousCorrelation/tauri-plugin-appload/tar.gz/95eb43e6036b34a1ddcf4c4deb941b198aa02e4b':
dependencies:
'@tauri-apps/api': 2.9.1