feat: reveal sandbox sub-options only when sandboxing is on

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 10:33:46 -04:00
parent 783bfee79f
commit bafc664251
2 changed files with 45 additions and 9 deletions
+19 -9
View File
@@ -63,15 +63,20 @@ class NewSessionScreen(
"bubblewrap not found — run `hqt doctor`",
id="sandbox-warning",
)
yield Label("Filesystem access:")
yield Select(
[("Read-write", "rw"), ("Read-only", "ro")],
id="fs-select",
value="rw",
allow_blank=False,
)
yield Label("Network:")
yield Switch(id="net-switch", value=True)
# Sub-options of the sandbox switch: only meaningful when sandboxing
# is on, so hidden until then (mirrors the worktree -> branch reveal).
sandbox_options = Vertical(id="sandbox-options")
sandbox_options.display = False
with sandbox_options:
yield Label("Filesystem access:")
yield Select(
[("Read-write", "rw"), ("Read-only", "ro")],
id="fs-select",
value="rw",
allow_blank=False,
)
yield Label("Network:")
yield Switch(id="net-switch", value=True)
with Horizontal(classes="dialog-actions"):
yield Button("OK", variant="primary", id="ok-btn")
yield Button("Cancel", id="cancel-btn")
@@ -89,6 +94,11 @@ class NewSessionScreen(
else:
branch_input.display = False
def on_switch_changed(self, event: Switch.Changed) -> None:
if event.switch.id != "sandbox-switch":
return
self.query_one("#sandbox-options", Vertical).display = event.value
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "ok-btn":
self._submit()
+26
View File
@@ -1869,3 +1869,29 @@ async def test_poll_sessions_dispatches_due_prompts_and_notifies():
mock_service.dispatch_due_prompts.assert_awaited_once()
assert any("Prompt sent" in call[0] for call in notify_calls)
@pytest.mark.asyncio
async def test_sandbox_options_hidden_until_switch_on():
"""The fs/net rows are sub-options of the sandbox switch: hidden until it is
turned on, shown when on, hidden again when turned back off."""
app = HqtApp()
async with app.run_test(size=(120, 40)) as pilot:
from hqt.tui.screens.new_session import NewSessionScreen
from textual.widgets import Switch
app.push_screen(
NewSessionScreen(["claude"], is_git_repo=True, sandbox_available=True)
)
await pilot.pause()
options = app.screen.query_one("#sandbox-options")
assert options.display is False
switch = app.screen.query_one("#sandbox-switch", Switch)
switch.value = True
await pilot.pause()
assert options.display is True
switch.value = False
await pilot.pause()
assert options.display is False