Skip to content

feat: make webui rpc timeout configurable - #1130

Open
khimaros wants to merge 1 commit into
moltis-org:mainfrom
khimaros:main
Open

feat: make webui rpc timeout configurable#1130
khimaros wants to merge 1 commit into
moltis-org:mainfrom
khimaros:main

Conversation

@khimaros

Copy link
Copy Markdown

written on the tin. fixes #1127

@greptile-apps

greptile-apps Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes the WebSocket RPC reply timeout configurable via server.rpc_timeout_ms in moltis.toml, with a default of 5000 ms matching the previous hardcoded value. The implementation follows the established gon pattern end-to-end: Rust config field → GonData injection → TypeScript consumer in rpcTimeoutMs().

  • Backend: adds rpc_timeout_ms: u64 to ServerConfig with serde default, registers the field in the schema map, and injects it into GonData; includes config template comment and documentation update.
  • Frontend: rpcTimeoutMs() in helpers.ts now prefers gon.get("rpc_timeout_ms") over the hardcoded constant (kept as a fallback for zero/negative misconfiguration); GonData TypeScript interface updated accordingly.
  • Tests: Rust unit tests for default/parsed values, schema-map validation test, and a Playwright E2E test that overrides the gon value to 1000 ms and verifies the timeout fires before 3000 ms.

Confidence Score: 5/5

Safe to merge — the change is additive, the default is identical to the previous hardcoded value, and the client-side fallback guards against zero/negative misconfiguration.

All five layers of the change (Rust config, gon injection, TypeScript consumer, TypeScript types, docs/template) are updated consistently and tested. The new rpcTimeoutMs() logic is simple and explicitly handles the edge case of a zero or negative configured value. E2E coverage proves the gon value is actually read at runtime. No existing behavior changes for users who don't set the field.

No files require special attention.

Important Files Changed

Filename Overview
crates/config/src/schema/system.rs Adds rpc_timeout_ms: u64 field with serde default of 5000 and updates Default impl — clean and consistent with surrounding fields.
crates/config/src/schema/tests.rs Two tests added: one asserts the default value is 5000, the other parses an explicit value from TOML. Good coverage of the new field.
crates/config/src/template.rs Adds a commented-out example line for rpc_timeout_ms in the generated config template — matches the established pattern for optional fields.
crates/config/src/validate/schema_map.rs Registers rpc_timeout_ms as a known Leaf in the schema map, preventing spurious unknown-field diagnostics.
crates/config/src/validate/tests/common.rs Adds validation test confirming rpc_timeout_ms is not flagged as an unknown field — mirrors the existing pattern for other server fields.
crates/web/src/templates.rs Adds rpc_timeout_ms: u64 to GonData and populates it from gw.config.server.rpc_timeout_ms — straightforward gon injection following established pattern.
crates/web/ui/src/helpers.ts rpcTimeoutMs() now reads from gon first (via new import), falling back to the hardcoded constant for invalid values; logic is clear and the defensive > 0 guard is correct.
crates/web/ui/e2e/specs/websocket.spec.js New E2E test overrides gon rpc_timeout_ms to 1000ms and verifies the TIMEOUT response arrives within 3000ms — good end-to-end coverage of the new behavior.
crates/web/ui/src/types/gon.ts Adds rpc_timeout_ms: number to the GonData TypeScript interface, keeping it in sync with the Rust struct.
docs/src/configuration-reference.md Documents rpc_timeout_ms in the [server] table with correct type, default, and description — placed in the correct position among neighboring fields.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["moltis.toml\nserver.rpc_timeout_ms"] --> B["ServerConfig::rpc_timeout_ms: u64\n(default: 5000)"]
    B --> C["build_gon_data()\nGonData.rpc_timeout_ms"]
    C --> D["gon JSON injected into HTML"]
    D --> E["gon.get('rpc_timeout_ms')\nin rpcTimeoutMs()"]
    E --> F{Valid positive number?}
    F -->|Yes| G["Use gon value as setTimeout delay"]
    F -->|No / 0 / negative| H["Fallback: RPC_TIMEOUT_MS = 5000ms"]
    G --> I["sendRpc setTimeout timer"]
    H --> I
    J["window.__moltisTestRpcTimeoutMs\n(test override)"] -->|Highest priority| I
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["moltis.toml\nserver.rpc_timeout_ms"] --> B["ServerConfig::rpc_timeout_ms: u64\n(default: 5000)"]
    B --> C["build_gon_data()\nGonData.rpc_timeout_ms"]
    C --> D["gon JSON injected into HTML"]
    D --> E["gon.get('rpc_timeout_ms')\nin rpcTimeoutMs()"]
    E --> F{Valid positive number?}
    F -->|Yes| G["Use gon value as setTimeout delay"]
    F -->|No / 0 / negative| H["Fallback: RPC_TIMEOUT_MS = 5000ms"]
    G --> I["sendRpc setTimeout timer"]
    H --> I
    J["window.__moltisTestRpcTimeoutMs\n(test override)"] -->|Highest priority| I
Loading

Reviews (1): Last reviewed commit: "feat: make webui rpc timeout configurabl..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: allow to configure rpc timeout

1 participant