mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(tui): address copilot review nits
This commit is contained in:
@@ -371,6 +371,7 @@ def test_complete_slash_details_args():
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert resp_root["result"]["replace_from"] == len("/details")
|
assert resp_root["result"]["replace_from"] == len("/details")
|
||||||
|
assert any(item["text"] == " thinking" for item in resp_root["result"]["items"])
|
||||||
assert any(item["text"] == "thinking" for item in resp_section["result"]["items"])
|
assert any(item["text"] == "thinking" for item in resp_section["result"]["items"])
|
||||||
assert any(item["text"] == "expanded" for item in resp_mode["result"]["items"])
|
assert any(item["text"] == "expanded" for item in resp_mode["result"]["items"])
|
||||||
|
|
||||||
|
|||||||
@@ -3692,6 +3692,13 @@ def _details_completion_item(value: str, meta: str = "") -> dict:
|
|||||||
return {"text": value, "display": value, "meta": meta}
|
return {"text": value, "display": value, "meta": meta}
|
||||||
|
|
||||||
|
|
||||||
|
def _details_root_completion_item(value: str, meta: str, needs_leading_space: bool) -> dict:
|
||||||
|
return _details_completion_item(
|
||||||
|
f" {value}" if needs_leading_space else value,
|
||||||
|
meta,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _details_completions(text: str) -> list[dict] | None:
|
def _details_completions(text: str) -> list[dict] | None:
|
||||||
if not text.lower().startswith("/details"):
|
if not text.lower().startswith("/details"):
|
||||||
return None
|
return None
|
||||||
@@ -3710,9 +3717,15 @@ def _details_completions(text: str) -> list[dict] | None:
|
|||||||
|
|
||||||
if not body or (len(parts) == 0 and has_trailing_space):
|
if not body or (len(parts) == 0 and has_trailing_space):
|
||||||
return [
|
return [
|
||||||
*[_details_completion_item(mode, "global mode") for mode in modes],
|
*[
|
||||||
_details_completion_item("cycle", "cycle global mode"),
|
_details_root_completion_item(mode, "global mode", not has_trailing_space)
|
||||||
*[_details_completion_item(section, "section override") for section in sections],
|
for mode in modes
|
||||||
|
],
|
||||||
|
_details_root_completion_item("cycle", "cycle global mode", not has_trailing_space),
|
||||||
|
*[
|
||||||
|
_details_root_completion_item(section, "section override", not has_trailing_space)
|
||||||
|
for section in sections
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
if len(parts) == 1 and not has_trailing_space:
|
if len(parts) == 1 and not has_trailing_space:
|
||||||
|
|||||||
@@ -472,7 +472,14 @@ export function TextInput({
|
|||||||
return stringWidth(current.slice(prevPos(current, cursor), cursor)) === 1
|
return stringWidth(current.slice(prevPos(current, cursor), cursor)) === 1
|
||||||
}
|
}
|
||||||
|
|
||||||
const commit = (next: string, nextCur: number, track = true, syncParent = true, syncLocal = true) => {
|
const commit = (
|
||||||
|
next: string,
|
||||||
|
nextCur: number,
|
||||||
|
track = true,
|
||||||
|
syncParent = true,
|
||||||
|
syncLocal = true,
|
||||||
|
nextLineWidth?: number
|
||||||
|
) => {
|
||||||
const prev = vRef.current
|
const prev = vRef.current
|
||||||
const c = snapPos(next, nextCur)
|
const c = snapPos(next, nextCur)
|
||||||
editVersionRef.current += 1
|
editVersionRef.current += 1
|
||||||
@@ -501,7 +508,7 @@ export function TextInput({
|
|||||||
|
|
||||||
curRef.current = c
|
curRef.current = c
|
||||||
vRef.current = next
|
vRef.current = next
|
||||||
lineWidthRef.current = stringWidth(next.includes('\n') ? next.slice(next.lastIndexOf('\n') + 1) : next)
|
lineWidthRef.current = nextLineWidth ?? stringWidth(next.includes('\n') ? next.slice(next.lastIndexOf('\n') + 1) : next)
|
||||||
|
|
||||||
if (next !== prev) {
|
if (next !== prev) {
|
||||||
if (syncParent) {
|
if (syncParent) {
|
||||||
@@ -509,6 +516,7 @@ export function TextInput({
|
|||||||
self.current = true
|
self.current = true
|
||||||
cbChange.current(next)
|
cbChange.current(next)
|
||||||
} else {
|
} else {
|
||||||
|
self.current = true
|
||||||
scheduleParentChange(next)
|
scheduleParentChange(next)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -768,7 +776,7 @@ export function TextInput({
|
|||||||
v = v.slice(0, t) + v.slice(c)
|
v = v.slice(0, t) + v.slice(c)
|
||||||
c = t
|
c = t
|
||||||
stdout!.write('\b \b')
|
stdout!.write('\b \b')
|
||||||
commit(v, c, true, false, false)
|
commit(v, c, true, false, false, Math.max(0, lineWidthRef.current - 1))
|
||||||
|
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@@ -855,7 +863,7 @@ export function TextInput({
|
|||||||
|
|
||||||
if (simpleAppend) {
|
if (simpleAppend) {
|
||||||
stdout!.write(text)
|
stdout!.write(text)
|
||||||
commit(v, c, true, false, false)
|
commit(v, c, true, false, false, lineWidthRef.current + stringWidth(text))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user