A terminal panel beside an agent chat

A real shell on the chat's own connection, opened and closed like the
inspector and never beside it. The modes govern the model; what a person
types is theirs, since they hold the credential and could open the same
shell with an ssh client. The model cannot see the panel -- a button
copies the output you choose into the composer.

The session outlives the socket: closing the panel leaves a build
running, and coming back reattaches with the scrollback. Two tabs share
one shell and the smaller window decides the size. It ends on an idle
timeout, on deleting the chat, on disabling, moving or deleting the
connection, and on a restart -- which says why rather than quietly
opening a fresh shell that has lost the working directory.

The nginx template's `Connection ""` is right for SSE and fails every
WebSocket handshake, so `location /` now uses a `map $http_upgrade`;
update.sh grows a drift check for it, because the only symptom on a
stale vhost is a panel that cannot connect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-08-02 01:44:07 +02:00
parent a1824681ae
commit 47791a88c7
37 changed files with 2889 additions and 31 deletions
@@ -177,6 +177,53 @@
</div>
</section>
<section class="card">
<h2 class="card__title">The terminal</h2>
<p class="field__hint">
A panel beside an agent chat holding an interactive shell on that chat's
own connection. What somebody types there is <em>theirs</em>: the modes and
the two lists above govern the model, not the person at the keyboard, who
could open the same shell with an ssh client. The model cannot see the
panel; sending it something is a button they press.
</p>
<div class="field">
<label class="checkbox">
<input type="checkbox" name="terminal_enabled" value="true"
{{ 'checked' if values.terminal_enabled }}>
<span>Allow the terminal panel</span>
</label>
<p class="field__hint">
People also need the <strong>Open a terminal</strong> permission.
{{ terminal_count }} shell{{ '' if terminal_count == 1 else 's' }} open right now.
</p>
</div>
<div class="field">
<label class="field__label" for="terminal_idle_timeout">Close a shell after</label>
<input class="input" id="terminal_idle_timeout" name="terminal_idle_timeout"
value="{{ values.terminal_idle_timeout }}" inputmode="numeric">
<p class="field__hint">
Seconds with nobody watching <em>and</em> nothing typed. Closing the
panel does not end the session — a build carries on and is still there
on the way back — so this is what eventually ends one.
</p>
</div>
<div class="field">
<label class="field__label" for="terminal_max_sessions">Most shells at once</label>
<input class="input" id="terminal_max_sessions" name="terminal_max_sessions"
value="{{ values.terminal_max_sessions }}" inputmode="numeric">
</div>
<div class="field">
<label class="field__label" for="terminal_max_per_user">Most shells per person</label>
<input class="input" id="terminal_max_per_user" name="terminal_max_per_user"
value="{{ values.terminal_max_per_user }}" inputmode="numeric">
<p class="field__hint">
One per chat. Each holds an SSH connection open on the far machine.
</p>
</div>
</section>
<div class="btn-row">
<button class="btn btn--primary" type="submit">Save changes</button>
</div>