feat(cli): improve tab and window tree rendering
- Add shared rendering helpers for width-aware tree labels, truncation, and no-wrap Rich text. - Preserve tab index and group window metadata through the extension and SDK factories. - Render tab trees in browser/window/index order with grouped tab details and optional shortened URLs. - Reuse the tab tree labels in window trees to keep output compact and consistent. - Cover legacy missing-index responses, grouped/collapsed tabs, URL display, and rendering helpers with tests.
This commit is contained in:
@@ -18,6 +18,7 @@ TAB_DATA = {
|
||||
"id": 10,
|
||||
"windowId": 1,
|
||||
"active": True,
|
||||
"index": 3,
|
||||
"title": "Example",
|
||||
"url": "https://example.com",
|
||||
"groupId": None,
|
||||
@@ -73,6 +74,15 @@ class TestBrowserCLIInit:
|
||||
assert b.remote == "browser-host.example:443"
|
||||
assert b.key == "agent"
|
||||
|
||||
def test_tab_factory_preserves_index(self):
|
||||
tab = BrowserCLI().tab_from(TAB_DATA)
|
||||
assert tab.index == 3
|
||||
|
||||
def test_tab_factory_defaults_missing_index_to_zero(self):
|
||||
data = {key: value for key, value in TAB_DATA.items() if key != "index"}
|
||||
tab = BrowserCLI().tab_from(data)
|
||||
assert tab.index == 0
|
||||
|
||||
def test_namespaces_present_and_bound(self):
|
||||
b = BrowserCLI()
|
||||
for name in ("nav", "tabs", "groups", "windows", "dom", "extract",
|
||||
|
||||
Reference in New Issue
Block a user