Skip to content

feat: Tern pane tools, a question card in sand's pane, and host commands with approval - #35

Merged
insertt merged 4 commits into
mainfrom
feat/tern-panes
Dec 2, 2026
Merged

insertt merged 4 commits into
mainfrom
feat/tern-panes

Conversation

@insertt

@insertt insertt commented Dec 2, 2026

Copy link
Copy Markdown
Owner

First of a stack of four PRs (Tern integration → nightly images → shared sandboxes and worktrees → Tern follow-ups). Review and merge in order.

feat: read Tern panes from the sandbox, and ask in Tern's own dialog

When sand runs in a Tern pane, the agent gets tern_ls (the window's panes,
not asked about) and tern_capture (a pane's text, with its scrollback if
asked). sand runs tern ls / tern capture on the host through the bridge
directory; reading a pane is confirmed once per pane for the session, panes
are named by id alone, and their text stays out of network-prompts.log.

The mod gives the tools to Claude Code's own UI, waiting through
node sand.mjs call, since a hook may not wait for the person; the MCP
server gives them over ACP.

In a Tern pane, sand's questions (allow a host, mount a directory, read a
pane) now float over sand's pane as a native Tern dialog
(sand tern-dialog), falling back to the system dialog;
SAND_TERN_DIALOG=0 keeps the system dialog.

feat: ask sand's questions in a card at the top of its Tern pane

In a Tern pane, sand's questions (a host to allow, a directory to mount, a
pane to read) now come up in a native Tern card at the top of sand's own
pane, over the agent's UI, which stays in sight and usable: the pointer goes
through to it, and the card fades while the pointer is on the pane. A long
question folds to three lines; minimize shrinks the card to a pulsing icon
at the pane's top right. This replaces the split dialog (sand tern-dialog).

sand only writes the surface (a screen surface, the kind Tern allows over
a program on the alternate screen, with listen: false): the pane's input
stays the agent's. The card's buttons are sand-answer:// links carrying a
secret per-question token, which sand's Tern plugin (assets/tern-plugin,
installed and updated by sand) claims, checks against sand's request file
and answers beside it. The plugin's styles keep the terminal visible under
the card and let the pointer through. Without Tern, or when the card cannot
be drawn, the system dialog asks; SAND_TERN_DIALOG=0 always uses it.

In Claude Code's own UI the mod sends a blocked host or a mount request
straight to the card (SAND_ASK_ON_HOST) instead of offering it in a row
above the prompt first. The e2e tests no longer inherit TERN_PANE.

feat: run commands on the host from the sandbox, with approval in Tern

tern_run lets the agent propose a command the sandbox lacks (docker or
podman, local servers and their logs, host-only tools). Each one is asked
about in sand's card, shown whole with its directory and the agent's
reason; on Allow it runs through the user's login shell in a new Tern pane
floating over sand's, which stays open, and the agent may read that pane
with tern_capture without a second question. Commands longer than 300
characters, spanning lines, or holding control, invisible or
direction-changing characters are refused without asking; nothing is
remembered between commands.

While sand asks in Tern, the agent is told when to reach for tern_run,
tern_ls and tern_capture: in Claude Code's system prompt from the mod
(prompt.compose), and in the MCP server's instructions over ACP.

The card now arrives expanded, highlighted with an amber ring that pulses
twice; the hover fade is gone (minimize stays). A plugin linked for
development is used while its major version matches, instead of sand
falling back to the system dialog.


Checked locally on stable Rust: cargo fmt --check, cargo clippy --all-targets --locked (with -D warnings) and cargo test --locked pass.

When sand runs in a Tern pane, the agent gets tern_ls (the window's panes,
not asked about) and tern_capture (a pane's text, with its scrollback if
asked). sand runs `tern ls` / `tern capture` on the host through the bridge
directory; reading a pane is confirmed once per pane for the session, panes
are named by id alone, and their text stays out of network-prompts.log.

The mod gives the tools to Claude Code's own UI, waiting through
`node sand.mjs call`, since a hook may not wait for the person; the MCP
server gives them over ACP.

In a Tern pane, sand's questions (allow a host, mount a directory, read a
pane) now float over sand's pane as a native Tern dialog
(`sand tern-dialog`), falling back to the system dialog;
SAND_TERN_DIALOG=0 keeps the system dialog.
In a Tern pane, sand's questions (a host to allow, a directory to mount, a
pane to read) now come up in a native Tern card at the top of sand's own
pane, over the agent's UI, which stays in sight and usable: the pointer goes
through to it, and the card fades while the pointer is on the pane. A long
question folds to three lines; minimize shrinks the card to a pulsing icon
at the pane's top right. This replaces the split dialog (`sand tern-dialog`).

sand only writes the surface (a `screen` surface, the kind Tern allows over
a program on the alternate screen, with `listen: false`): the pane's input
stays the agent's. The card's buttons are `sand-answer://` links carrying a
secret per-question token, which sand's Tern plugin (assets/tern-plugin,
installed and updated by sand) claims, checks against sand's request file
and answers beside it. The plugin's styles keep the terminal visible under
the card and let the pointer through. Without Tern, or when the card cannot
be drawn, the system dialog asks; SAND_TERN_DIALOG=0 always uses it.

In Claude Code's own UI the mod sends a blocked host or a mount request
straight to the card (SAND_ASK_ON_HOST) instead of offering it in a row
above the prompt first. The e2e tests no longer inherit TERN_PANE.
tern_run lets the agent propose a command the sandbox lacks (docker or
podman, local servers and their logs, host-only tools). Each one is asked
about in sand's card, shown whole with its directory and the agent's
reason; on Allow it runs through the user's login shell in a new Tern pane
floating over sand's, which stays open, and the agent may read that pane
with tern_capture without a second question. Commands longer than 300
characters, spanning lines, or holding control, invisible or
direction-changing characters are refused without asking; nothing is
remembered between commands.

While sand asks in Tern, the agent is told when to reach for tern_run,
tern_ls and tern_capture: in Claude Code's system prompt from the mod
(prompt.compose), and in the MCP server's instructions over ACP.

The card now arrives expanded, highlighted with an amber ring that pulses
twice; the hover fade is gone (minimize stays). A plugin linked for
development is used while its major version matches, instead of sand
falling back to the system dialog.
It stopped answering after about 5 seconds, so when node was slow to start (a Windows runner took over 5 minutes for the suite) the request came too late and the server reported that sand did not answer.
@insertt
insertt merged commit 57b3642 into main Dec 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant