fix(console): accept the --force override the held-store refusal advertises
The Desktop/dashboard console printed `hermes sessions optimize --force` as the override, but _sessions_optimize rejected every argument — with a gateway running the command could only ever refuse. It now parses --force itself (and the hint names the console form).
This commit is contained in:
@@ -706,10 +706,13 @@ def _sessions_rename(_engine: HermesConsoleEngine, args: list[str]) -> None:
|
||||
|
||||
@_captured
|
||||
def _sessions_optimize(_engine: HermesConsoleEngine, args: list[str]) -> None:
|
||||
_expect_no_args(args, "sessions optimize")
|
||||
# --force is parsed HERE: the refusal below points at it, and a hint the surface cannot
|
||||
# accept would make this command refuse forever whenever a gateway is running.
|
||||
ns = _parse("sessions optimize", args, (("--force",), dict(action="store_true")))
|
||||
with _session_db(read_only=False) as db:
|
||||
from hermes_state_holders import held_store_refusal
|
||||
refusal = held_store_refusal(db.db_path, command="optimize", force_hint="`hermes sessions optimize --force`")
|
||||
refusal = None if ns.force else held_store_refusal(
|
||||
db.db_path, command="optimize", force_hint="`sessions optimize --force`")
|
||||
if refusal:
|
||||
raise ConsoleCommandError(refusal)
|
||||
print(f"Optimized {db.vacuum()} FTS index(es).")
|
||||
@@ -824,7 +827,7 @@ _BUILTIN_COMMANDS = (
|
||||
"Export sessions to JSONL.", _sessions_export, "Export session data?"),
|
||||
(("sessions", "rename"), "sessions rename <session> <title>", "Rename a session.",
|
||||
_sessions_rename, "Rename this session?"),
|
||||
(("sessions", "optimize"), "sessions optimize", "Optimize the session store.",
|
||||
(("sessions", "optimize"), "sessions optimize [--force]", "Optimize the session store.",
|
||||
_sessions_optimize, "Optimize the session database?"),
|
||||
(("sessions", "repair"), "sessions repair [--check-only] [--no-backup]",
|
||||
"Repair a malformed session database schema.", _sessions_repair,
|
||||
|
||||
@@ -241,6 +241,15 @@ MUTATING_CONFIRMATION_SMOKE_COMMANDS = [
|
||||
|
||||
|
||||
|
||||
def test_sessions_optimize_accepts_the_force_override_it_advertises(_isolate_hermes_home):
|
||||
"""The held-store refusal this command prints points at `sessions optimize --force`; if the
|
||||
console rejected the flag, the command could only ever refuse whenever a gateway is running."""
|
||||
result = HermesConsoleEngine().execute("sessions optimize --force", confirmed=True)
|
||||
|
||||
assert result.status == "ok", result.output
|
||||
assert "Usage:" not in result.output
|
||||
|
||||
|
||||
def test_sessions_list_and_stats_use_isolated_session_store(_isolate_hermes_home):
|
||||
from hermes_state import SessionDB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user