Skip to content

Commit 929b86e

Browse files
committed
feat(ui): delete sessions from Control UI
1 parent 76d3d58 commit 929b86e

5 files changed

Lines changed: 43 additions & 8 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- TUI: show provider/model labels for the active session and default model.
2828
- Heartbeat: add per-agent heartbeat configuration and multi-agent docs example.
2929
- UI: show gateway auth guidance + doc link on unauthorized Control UI connections.
30+
- UI: add session deletion action in Control UI sessions list. (#1017) — thanks @Szpadel.
3031
- Security: warn on weak model tiers (Haiku, below GPT-5, below Claude 4.5) in `clawdbot security audit`.
3132
- Apps: store node auth tokens encrypted (Keychain/SecurePrefs).
3233
- Cron: isolated cron jobs now start a fresh session id on every run to prevent context buildup.

‎ui/src/styles/components.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@
537537
.table-head,
538538
.table-row {
539539
display: grid;
540-
grid-template-columns: 1.4fr 0.8fr 0.8fr 0.7fr 0.8fr 0.8fr;
540+
grid-template-columns: 1.4fr 1fr 0.8fr 0.7fr 0.8fr 0.8fr 0.8fr 0.8fr 0.6fr;
541541
gap: 12px;
542542
align-items: center;
543543
}

‎ui/src/ui/app-render.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import {
5757
updateTelegramForm,
5858
} from "./controllers/connections";
5959
import { loadPresence } from "./controllers/presence";
60-
import { loadSessions, patchSession } from "./controllers/sessions";
60+
import { deleteSession, loadSessions, patchSession } from "./controllers/sessions";
6161
import {
6262
installSkill,
6363
loadSkills,
@@ -277,11 +277,12 @@ export function renderApp(state: AppViewState) {
277277
state.sessionsFilterLimit = next.limit;
278278
state.sessionsIncludeGlobal = next.includeGlobal;
279279
state.sessionsIncludeUnknown = next.includeUnknown;
280-
},
281-
onRefresh: () => loadSessions(state),
282-
onPatch: (key, patch) => patchSession(state, key, patch),
283-
})
284-
: nothing}
280+
},
281+
onRefresh: () => loadSessions(state),
282+
onPatch: (key, patch) => patchSession(state, key, patch),
283+
onDelete: (key) => deleteSession(state, key),
284+
})
285+
: nothing}
285286
286287
${state.tab === "cron"
287288
? renderCron({

‎ui/src/ui/controllers/sessions.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,22 @@ export async function patchSession(
6060
state.sessionsError = String(err);
6161
}
6262
}
63+
64+
export async function deleteSession(state: SessionsState, key: string) {
65+
if (!state.client || !state.connected) return;
66+
if (state.sessionsLoading) return;
67+
const confirmed = window.confirm(
68+
`Delete session "${key}"?\n\nDeletes the session entry and archives its transcript.`,
69+
);
70+
if (!confirmed) return;
71+
state.sessionsLoading = true;
72+
state.sessionsError = null;
73+
try {
74+
await state.client.request("sessions.delete", { key, deleteTranscript: true });
75+
await loadSessions(state);
76+
} catch (err) {
77+
state.sessionsError = String(err);
78+
} finally {
79+
state.sessionsLoading = false;
80+
}
81+
}

‎ui/src/ui/views/sessions.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type SessionsProps = {
2929
reasoningLevel?: string | null;
3030
},
3131
) => void;
32+
onDelete: (key: string) => void;
3233
};
3334

3435
const THINK_LEVELS = ["", "off", "minimal", "low", "medium", "high"] as const;
@@ -157,10 +158,13 @@ export function renderSessions(props: SessionsProps) {
157158
<div>Thinking</div>
158159
<div>Verbose</div>
159160
<div>Reasoning</div>
161+
<div>Actions</div>
160162
</div>
161163
${rows.length === 0
162164
? html`<div class="muted">No sessions found.</div>`
163-
: rows.map((row) => renderRow(row, props.basePath, props.onPatch))}
165+
: rows.map((row) =>
166+
renderRow(row, props.basePath, props.onPatch, props.onDelete, props.loading),
167+
)}
164168
</div>
165169
</section>
166170
`;
@@ -170,6 +174,8 @@ function renderRow(
170174
row: GatewaySessionRow,
171175
basePath: string,
172176
onPatch: SessionsProps["onPatch"],
177+
onDelete: SessionsProps["onDelete"],
178+
disabled: boolean,
173179
) {
174180
const updated = row.updatedAt ? formatAgo(row.updatedAt) : "n/a";
175181
const rawThinking = row.thinkingLevel ?? "";
@@ -196,6 +202,7 @@ function renderRow(
196202
<div>
197203
<select
198204
.value=${thinking}
205+
?disabled=${disabled}
199206
@change=${(e: Event) => {
200207
const value = (e.target as HTMLSelectElement).value;
201208
onPatch(row.key, {
@@ -211,6 +218,7 @@ function renderRow(
211218
<div>
212219
<select
213220
.value=${verbose}
221+
?disabled=${disabled}
214222
@change=${(e: Event) => {
215223
const value = (e.target as HTMLSelectElement).value;
216224
onPatch(row.key, { verboseLevel: value || null });
@@ -224,6 +232,7 @@ function renderRow(
224232
<div>
225233
<select
226234
.value=${reasoning}
235+
?disabled=${disabled}
227236
@change=${(e: Event) => {
228237
const value = (e.target as HTMLSelectElement).value;
229238
onPatch(row.key, { reasoningLevel: value || null });
@@ -234,6 +243,11 @@ function renderRow(
234243
)}
235244
</select>
236245
</div>
246+
<div>
247+
<button class="btn danger" ?disabled=${disabled} @click=${() => onDelete(row.key)}>
248+
Delete
249+
</button>
250+
</div>
237251
</div>
238252
`;
239253
}

0 commit comments

Comments
 (0)