feat: add reset-windows entry to the tool palette

Hook the existing tmux window-index reset into the Alt+p tool palette,
special-cased like clone: selecting 'reset-windows' compacts the hqt
session's window indexes (keeping the home window at 0) via
TmuxManager.reset_window_indexes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-11 10:14:04 -04:00
parent f5c97d1fe0
commit 5b4e800883
2 changed files with 48 additions and 4 deletions
+36
View File
@@ -75,6 +75,41 @@ def test_tool_cmd_clone_dispatches_to_clone(monkeypatch, tmp_path):
assert calls["clone"] == "hqt-5"
def test_tool_cmd_reset_windows_dispatches_to_manager(monkeypatch, tmp_path):
monkeypatch.setattr(
"hqt.config.get_settings", lambda: Settings(db_path=tmp_path / "t.db")
)
calls = {}
async def fake_reset(self, home_window):
calls["home"] = home_window
return True
monkeypatch.setattr("hqt.tmux.manager.TmuxManager.reset_window_indexes", fake_reset)
result = CliRunner().invoke(cli.main, ["tool", "reset-windows", "hqt-5"])
assert result.exit_code == 0, result.output
# Compacts against the configured home/TUI window, not the trigger window.
assert calls["home"] == Settings(db_path=tmp_path / "t.db").tui_window_name
def test_tool_cmd_reset_windows_failure_reports_error(monkeypatch, tmp_path):
monkeypatch.setattr(
"hqt.config.get_settings", lambda: Settings(db_path=tmp_path / "t.db")
)
async def fake_reset(self, home_window):
return False
monkeypatch.setattr("hqt.tmux.manager.TmuxManager.reset_window_indexes", fake_reset)
result = CliRunner().invoke(cli.main, ["tool", "reset-windows", "hqt-5"])
assert result.exit_code == 1
assert "reset window indexes" in result.output
def test_tool_cmd_reports_service_error(monkeypatch, tmp_path):
from hqt.errors import ServiceError
@@ -115,6 +150,7 @@ def test_palette_cmd_shows_popup_for_session_window(monkeypatch, tmp_path):
popup_cmd = argv[-1]
assert "fzf" in popup_cmd
assert "nvim" in popup_cmd and "clone" in popup_cmd
assert "reset-windows" in popup_cmd
# the window is baked into the command for `hqt tool {} <window>`
assert "hqt-5" in popup_cmd