mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
yellow X is to clean up sessions
This commit is contained in:
parent
177856d5aa
commit
136ca9ff29
1 changed files with 16 additions and 6 deletions
|
|
@ -105,19 +105,27 @@ export class SessionCard extends LitElement {
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
// Send kill request
|
// Send kill or cleanup request based on session status
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/sessions/${this.session.id}`, {
|
// Use different endpoint based on session status
|
||||||
|
const endpoint =
|
||||||
|
this.session.status === 'exited'
|
||||||
|
? `/api/sessions/${this.session.id}/cleanup`
|
||||||
|
: `/api/sessions/${this.session.id}`;
|
||||||
|
|
||||||
|
const action = this.session.status === 'exited' ? 'cleanup' : 'kill';
|
||||||
|
|
||||||
|
const response = await fetch(endpoint, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.text();
|
const errorData = await response.text();
|
||||||
logger.error('Failed to kill session', { errorData, sessionId: this.session.id });
|
logger.error(`Failed to ${action} session`, { errorData, sessionId: this.session.id });
|
||||||
throw new Error(`Kill failed: ${response.status}`);
|
throw new Error(`${action} failed: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill succeeded - dispatch event to notify parent components
|
// Kill/cleanup succeeded - dispatch event to notify parent components
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('session-killed', {
|
new CustomEvent('session-killed', {
|
||||||
detail: {
|
detail: {
|
||||||
|
|
@ -129,7 +137,9 @@ export class SessionCard extends LitElement {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.log('Session killed successfully', { sessionId: this.session.id });
|
logger.log(
|
||||||
|
`Session ${this.session.id} ${action === 'cleanup' ? 'cleaned up' : 'killed'} successfully`
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error killing session', { error, sessionId: this.session.id });
|
logger.error('Error killing session', { error, sessionId: this.session.id });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue