mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(tui): address review feedback
This commit is contained in:
@@ -356,6 +356,9 @@ def test_complete_slash_includes_tui_details_command():
|
||||
|
||||
|
||||
def test_complete_slash_details_args():
|
||||
resp_root = server.handle_request(
|
||||
{"id": "0", "method": "complete.slash", "params": {"text": "/details"}}
|
||||
)
|
||||
resp_section = server.handle_request(
|
||||
{"id": "1", "method": "complete.slash", "params": {"text": "/details t"}}
|
||||
)
|
||||
@@ -367,6 +370,7 @@ def test_complete_slash_details_args():
|
||||
}
|
||||
)
|
||||
|
||||
assert resp_root["result"]["replace_from"] == len("/details")
|
||||
assert any(item["text"] == "thinking" for item in resp_section["result"]["items"])
|
||||
assert any(item["text"] == "expanded" for item in resp_mode["result"]["items"])
|
||||
|
||||
|
||||
@@ -3822,7 +3822,10 @@ def _(rid, params: dict) -> dict:
|
||||
if details_items is not None:
|
||||
return _ok(
|
||||
rid,
|
||||
{"items": details_items, "replace_from": text.rfind(" ") + 1},
|
||||
{
|
||||
"items": details_items,
|
||||
"replace_from": text.rfind(" ") + 1 if " " in text else len(text),
|
||||
},
|
||||
)
|
||||
|
||||
return _ok(
|
||||
|
||||
@@ -42,9 +42,10 @@ describe('input metrics helpers', () => {
|
||||
expect(inputVisualHeight('one\ntwo', 40)).toBe(2)
|
||||
})
|
||||
|
||||
it('reserves a stable transcript scrollbar gutter for composer width', () => {
|
||||
it('reserves gutters without exceeding the physical terminal width', () => {
|
||||
expect(stableComposerColumns(100, 3)).toBe(93)
|
||||
expect(stableComposerColumns(10, 3)).toBe(20)
|
||||
expect(stableComposerColumns(10, 3)).toBe(3)
|
||||
expect(stableComposerColumns(6, 3)).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ export function inputVisualHeight(value: string, columns: number) {
|
||||
}
|
||||
|
||||
export function stableComposerColumns(totalCols: number, promptWidth: number) {
|
||||
// totalCols is the terminal width. Reserve:
|
||||
// Physical render/wrap width. Reserve:
|
||||
// - outer composer paddingX={1}: 2 columns
|
||||
// - transcript scrollbar gutter + marginLeft: 2 columns
|
||||
// - prompt prefix width
|
||||
return Math.max(20, totalCols - promptWidth - 4)
|
||||
return Math.max(1, totalCols - promptWidth - 4)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user