feat: make webui rpc timeout configurable - #1130
Conversation
Greptile SummaryThis PR makes the WebSocket RPC reply timeout configurable via
Confidence Score: 5/5Safe 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.
|
| 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
%%{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
Reviews (1): Last reviewed commit: "feat: make webui rpc timeout configurabl..." | Re-trigger Greptile
written on the tin. fixes #1127