Improve TUI startup and keep plugin toggles responsive

Auto-open the plugin table when only one installation exists, run enable and
disable work off the UI thread with immediate status feedback, and skip the
back action for single-instance setups.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
pleb
2026-07-01 22:56:52 -07:00
parent c86e51b85a
commit b75d8ccc57
3 changed files with 85 additions and 35 deletions
+17 -5
View File
@@ -1496,16 +1496,27 @@ class PluginHelperTuiTests(unittest.IsolatedAsyncioTestCase):
self.assertEqual(table.row_count, 2)
self.assertEqual(app.mode, "installations")
async def test_single_instance_skips_installation_picker(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
app, _instance, _state = _make_tui_fixture(Path(tmp))
async with app.run_test():
self.assertEqual(app.mode, "plugins")
self.assertEqual(app.selected_installation, app.choices[0])
table = app.query_one(DataTable)
self.assertEqual(table.row_count, 1)
async def test_space_disables_enabled_plugin_without_id_prompt(self) -> None:
with tempfile.TemporaryDirectory() as tmp:
app, instance, state = _make_tui_fixture(Path(tmp))
async with app.run_test() as pilot:
await pilot.press("enter")
self.assertEqual(app.mode, "plugins")
self.assertEqual(app.plugin_rows[0]["status"], "enabled")
table = app.query_one(DataTable)
self.assertEqual(table.get_cell_at(Coordinate(0, 0)), Text("[x]", no_wrap=True))
await pilot.press("space")
await pilot.pause()
self.assertFalse((instance / "Plugins" / "Example.dll").exists())
updated = load_installed_state(state, "1.40.8")
@@ -1517,9 +1528,10 @@ class PluginHelperTuiTests(unittest.IsolatedAsyncioTestCase):
app, instance, state = _make_tui_fixture(Path(tmp), disabled=True)
async with app.run_test() as pilot:
await pilot.press("enter")
self.assertEqual(app.mode, "plugins")
self.assertEqual(app.plugin_rows[0]["status"], "disabled")
await pilot.press("space")
await pilot.pause()
self.assertEqual((instance / "Plugins" / "Example.dll").read_bytes(), b"managed dll")
updated = load_installed_state(state, "1.40.8")
@@ -1531,8 +1543,8 @@ class PluginHelperTuiTests(unittest.IsolatedAsyncioTestCase):
app, instance, state = _make_tui_fixture(Path(tmp))
async with app.run_test() as pilot:
await pilot.press("enter")
await pilot.press("d")
await pilot.pause()
self.assertFalse((instance / "Plugins" / "Example.dll").exists())
updated = load_installed_state(state, "1.40.8")
@@ -1545,8 +1557,8 @@ class PluginHelperTuiTests(unittest.IsolatedAsyncioTestCase):
app, instance, state = _make_tui_fixture(Path(tmp), disabled=True)
async with app.run_test() as pilot:
await pilot.press("enter")
await pilot.press("e")
await pilot.pause()
self.assertEqual((instance / "Plugins" / "Example.dll").read_bytes(), b"managed dll")
updated = load_installed_state(state, "1.40.8")
@@ -1559,8 +1571,8 @@ class PluginHelperTuiTests(unittest.IsolatedAsyncioTestCase):
app, instance, state = _make_tui_fixture(Path(tmp), hash_mismatch=True)
async with app.run_test() as pilot:
await pilot.press("enter")
await pilot.press("space")
await pilot.pause()
self.assertEqual((instance / "Plugins" / "Example.dll").read_bytes(), b"changed dll")
updated = load_installed_state(state, "1.40.8")