fix(tui): persist model switches by default

This commit is contained in:
Brooklyn Nicholson
2026-04-26 02:15:10 -05:00
parent 14fcff60c9
commit 458ce792d2
5 changed files with 150 additions and 14 deletions

View File

@@ -3710,6 +3710,65 @@ def _(rid, params: dict) -> dict:
return _ok(rid, {"items": items})
def _details_completion_item(value: str, meta: str = "") -> dict:
return {"text": value, "display": value, "meta": meta}
def _details_completions(text: str) -> list[dict] | None:
if not text.lower().startswith("/details"):
return None
stripped = text.strip()
if stripped and not "/details".startswith(stripped.lower().split()[0]):
return None
body = text[len("/details"):]
if body.startswith(" "):
body = body[1:]
parts = body.split()
has_trailing_space = text.endswith(" ")
sections = ("thinking", "tools", "subagents", "activity")
modes = ("hidden", "collapsed", "expanded")
if not body or (len(parts) == 0 and has_trailing_space):
return [
*[_details_completion_item(mode, "global mode") for mode in modes],
_details_completion_item("cycle", "cycle global mode"),
*[_details_completion_item(section, "section override") for section in sections],
]
if len(parts) == 1 and not has_trailing_space:
prefix = parts[0].lower()
candidates = [*modes, "cycle", *sections]
return [
_details_completion_item(
candidate,
"section override" if candidate in sections else "global mode",
)
for candidate in candidates
if candidate.startswith(prefix) and candidate != prefix
]
if len(parts) == 1 and has_trailing_space and parts[0].lower() in sections:
return [
*[_details_completion_item(mode, f"set {parts[0].lower()}") for mode in modes],
_details_completion_item("reset", f"clear {parts[0].lower()} override"),
]
if len(parts) == 2 and not has_trailing_space and parts[0].lower() in sections:
prefix = parts[1].lower()
return [
_details_completion_item(
candidate,
f"clear {parts[0].lower()} override" if candidate == "reset" else f"set {parts[0].lower()}",
)
for candidate in (*modes, "reset")
if candidate.startswith(prefix) and candidate != prefix
]
return []
@method("complete.slash")
def _(rid, params: dict) -> dict:
text = params.get("text", "")
@@ -3742,6 +3801,11 @@ def _(rid, params: dict) -> dict:
"display": "/compact",
"meta": "Toggle compact display mode",
},
{
"text": "/details",
"display": "/details",
"meta": "Control agent detail visibility",
},
{
"text": "/logs",
"display": "/logs",
@@ -3753,6 +3817,14 @@ def _(rid, params: dict) -> dict:
item["text"] == extra["text"] for item in items
):
items.append(extra)
details_items = _details_completions(text)
if details_items is not None:
return _ok(
rid,
{"items": details_items, "replace_from": text.rfind(" ") + 1},
)
return _ok(
rid,
{"items": items, "replace_from": text.rfind(" ") + 1 if " " in text else 1},