From 377adb10b20e841e1cd89331c8175bf1c482241c Mon Sep 17 00:00:00 2001 From: Phillip Tarrant Date: Fri, 10 Jul 2026 15:00:40 -0500 Subject: [PATCH] feat(client): ProxyConfig.request_timeout_seconds (default 35s, reject <=0) Co-Authored-By: Claude Opus 4.8 (1M context) --- client/scripts/net/proxy_config.gd | 11 +++++++++++ client/tests/unit/test_net_primitives.gd | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/client/scripts/net/proxy_config.gd b/client/scripts/net/proxy_config.gd index 7573518..fecd109 100644 --- a/client/scripts/net/proxy_config.gd +++ b/client/scripts/net/proxy_config.gd @@ -7,8 +7,19 @@ extends RefCounted const SETTING := "coc_rpg/proxy_base_url" const DEFAULT := "http://localhost:8000" +const TIMEOUT_SETTING := "coc_rpg/proxy_request_timeout_seconds" +const TIMEOUT_DEFAULT := 35.0 + static func base_url() -> String: var v = ProjectSettings.get_setting(SETTING, DEFAULT) var s := str(v) return s if s != "" else DEFAULT + + +static func request_timeout_seconds() -> float: + # Just above the server's OLLAMA_TIMEOUT_SECONDS (30) so a slow model surfaces + # the server's own error first, while a fully-hung proxy is still bounded. A + # non-positive value would re-enable the infinite hang, so reject it. + var v := float(ProjectSettings.get_setting(TIMEOUT_SETTING, TIMEOUT_DEFAULT)) + return v if v > 0.0 else TIMEOUT_DEFAULT diff --git a/client/tests/unit/test_net_primitives.gd b/client/tests/unit/test_net_primitives.gd index 9a6a2ca..b26f64c 100644 --- a/client/tests/unit/test_net_primitives.gd +++ b/client/tests/unit/test_net_primitives.gd @@ -62,3 +62,19 @@ func test_npc_result_fallback_is_degraded_with_no_moves(): assert_eq(r.valid_moves, []) assert_eq(r.facts, []) assert_false(r.ends_conversation) + + +func test_request_timeout_default(): + if ProjectSettings.has_setting(ProxyConfig.TIMEOUT_SETTING): + ProjectSettings.clear(ProxyConfig.TIMEOUT_SETTING) + assert_eq(ProxyConfig.request_timeout_seconds(), ProxyConfig.TIMEOUT_DEFAULT) + + +func test_request_timeout_override_and_reject_nonpositive(): + var ProxyConfig = preload("res://scripts/net/proxy_config.gd") + ProjectSettings.set_setting(ProxyConfig.TIMEOUT_SETTING, 12.5) + assert_eq(ProxyConfig.request_timeout_seconds(), 12.5) + # A non-positive override must NOT re-enable the hang — falls back to default. + ProjectSettings.set_setting(ProxyConfig.TIMEOUT_SETTING, 0.0) + assert_eq(ProxyConfig.request_timeout_seconds(), ProxyConfig.TIMEOUT_DEFAULT) + ProjectSettings.clear(ProxyConfig.TIMEOUT_SETTING)