operator control: /compact slash command + endpoint
new POST /api/compact on the per-agent web UI: spawns turn::compact_session in the background so the http handler returns immediately. claude runs '/compact' over the persistent --continue session; output streams into the live panel like any other turn. slash command /compact wired to the new endpoint. SLASH_COMMANDS list now lists all four (/help /clear /cancel /compact). postCancelTurn + postCompact share a postSimple() helper. deliberately not gated against an in-flight turn — claude's own session lock will reject a concurrent compact and the failure surfaces as a Note in the live panel.
This commit is contained in:
parent
5ee65d2f15
commit
c9647f4106
2 changed files with 45 additions and 7 deletions
|
|
@ -161,23 +161,26 @@
|
|||
let termAPI = null;
|
||||
|
||||
const SLASH_COMMANDS = [
|
||||
{ name: '/help', desc: 'list slash commands' },
|
||||
{ name: '/clear', desc: 'wipe the terminal panel (local-only)' },
|
||||
{ name: '/cancel', desc: 'SIGINT the in-flight claude turn' },
|
||||
{ name: '/help', desc: 'list slash commands' },
|
||||
{ name: '/clear', desc: 'wipe the terminal panel (local-only)' },
|
||||
{ name: '/cancel', desc: 'SIGINT the in-flight claude turn' },
|
||||
{ name: '/compact', desc: 'compact the persistent claude session' },
|
||||
];
|
||||
|
||||
async function postCancelTurn() {
|
||||
async function postSimple(url, label) {
|
||||
try {
|
||||
const resp = await fetch('/api/cancel', { method: 'POST', redirect: 'manual' });
|
||||
const resp = await fetch(url, { method: 'POST', redirect: 'manual' });
|
||||
const ok = resp.ok || resp.type === 'opaqueredirect'
|
||||
|| (resp.status >= 200 && resp.status < 400);
|
||||
if (!ok && termAPI) {
|
||||
termAPI.row('turn-end-fail', '✗ /cancel failed: http ' + resp.status);
|
||||
termAPI.row('turn-end-fail', '✗ ' + label + ' failed: http ' + resp.status);
|
||||
}
|
||||
} catch (err) {
|
||||
if (termAPI) termAPI.row('turn-end-fail', '✗ /cancel failed: ' + err);
|
||||
if (termAPI) termAPI.row('turn-end-fail', '✗ ' + label + ' failed: ' + err);
|
||||
}
|
||||
}
|
||||
const postCancelTurn = () => postSimple('/api/cancel', '/cancel');
|
||||
const postCompact = () => postSimple('/api/compact', '/compact');
|
||||
|
||||
function handleSlashCommand(line) {
|
||||
if (!termAPI) return false;
|
||||
|
|
@ -198,6 +201,9 @@
|
|||
case '/cancel':
|
||||
postCancelTurn();
|
||||
return true;
|
||||
case '/compact':
|
||||
postCompact();
|
||||
return true;
|
||||
default:
|
||||
termAPI.row('turn-end-fail', '✗ unknown slash command: ' + cmd + ' — try /help');
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue