Show auto-close as off when partial manual-complete is enabled.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+34
@@ -193,6 +193,10 @@ def _effective_env_value(key: str, file_values: dict[str, str], schema_default:
|
||||
return _RUNTIME_ENV_DEFAULTS.get(key, "")
|
||||
|
||||
|
||||
def _env_truthy(raw: str) -> bool:
|
||||
return str(raw or "").strip().lower() in ("1", "true", "yes", "on")
|
||||
|
||||
|
||||
def _schema_field_map(example_path: str) -> dict[str, dict[str, Any]]:
|
||||
out: dict[str, dict[str, Any]] = {}
|
||||
for group in parse_env_example_schema(example_path):
|
||||
@@ -211,6 +215,13 @@ def _build_field(
|
||||
meta = schema.get(key) or {}
|
||||
schema_default = meta.get("default") or ""
|
||||
val = _effective_env_value(key, values, schema_default)
|
||||
# 与运行时一致:手动补开开启时,「自动平期权」展示为关闭(实际也不会执行)
|
||||
if key == "HEDGE_PLAN_PARTIAL_AUTO_CLOSE_OPTION":
|
||||
manual = _effective_env_value(
|
||||
"HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL", values, "true"
|
||||
)
|
||||
if _env_truthy(manual):
|
||||
val = "false"
|
||||
masked = _mask_value(key, val)
|
||||
ftype = meta.get("type") or _field_type(key, val or schema_default)
|
||||
options = select_options_for(key)
|
||||
@@ -322,3 +333,26 @@ def validate_env_ui_updates(
|
||||
)
|
||||
groups.append({"title": sec["title"], "fields": fields})
|
||||
return validate_env_updates(groups, updates)
|
||||
|
||||
|
||||
def coerce_hedge_partial_close_with_manual(
|
||||
clean: dict[str, str],
|
||||
*,
|
||||
env_path: str = "",
|
||||
) -> dict[str, str]:
|
||||
"""手动补开为开启时,强制把自动平写成 false(与运行时一致)."""
|
||||
out = dict(clean or {})
|
||||
manual = out.get("HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL")
|
||||
if manual is None and env_path:
|
||||
try:
|
||||
from lib.env.env_file_lib import env_get_all, read_env_lines
|
||||
|
||||
file_vals = env_get_all(read_env_lines(env_path))
|
||||
manual = _effective_env_value(
|
||||
"HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL", file_vals, "true"
|
||||
)
|
||||
except Exception:
|
||||
manual = "true"
|
||||
if _env_truthy(str(manual or "")):
|
||||
out["HEDGE_PLAN_PARTIAL_AUTO_CLOSE_OPTION"] = "false"
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user