feat(sessions): add stop confirmation, health checks, and tunnel recreation

- Add inline confirmation dialog before stopping instances
- Delete instances from state immediately without page reload
- Add health check polling every 30s for running instances
- Show tunnel error badge when tunnel is unreachable
- Add 'Fix Tunnel' button to recreate broken tunnels
- Update API client with health check and tunnel recreation endpoints
This commit is contained in:
Fusion
2026-05-20 16:49:31 +02:00
parent e985f0122e
commit 6ec35988cc
13 changed files with 669 additions and 35 deletions
@@ -0,0 +1,34 @@
## ADDED Requirements
### Requirement: Stopping a session requires confirmation
The system SHALL display a confirmation dialog before stopping a running session.
#### Scenario: User initiates stop
- **WHEN** user clicks the "Stop" button on a running session
- **THEN** a confirmation dialog appears asking "Are you sure you want to stop this session?"
- **AND** the dialog provides "Cancel" and "Stop" options
#### Scenario: User confirms stop
- **WHEN** user clicks "Stop" in the confirmation dialog
- **THEN** the session stops
- **AND** the dialog closes
#### Scenario: User cancels stop
- **WHEN** user clicks "Cancel" in the confirmation dialog
- **THEN** the dialog closes
- **AND** the session remains running
### Requirement: Deleted sessions disappear from UI immediately
The system SHALL update the frontend state immediately after a session is successfully deleted.
#### Scenario: Delete session
- **WHEN** user deletes a session
- **AND** the delete API call returns success
- **THEN** the session is removed from the visible list
- **AND** no page reload is required
#### Scenario: Delete session failure
- **WHEN** user deletes a session
- **AND** the delete API call fails
- **THEN** the session remains in the list
- **AND** an error message is displayed
@@ -0,0 +1,46 @@
## MODIFIED Requirements
### Requirement: Tool Lifecycle
The system SHALL manage tool lifecycle operations including tunnel recreation.
#### Scenario: Stop tool
- GIVEN a running tool instance
- WHEN the user stops it
- THEN `docker compose stop` is executed
- AND the cloudflared tunnel process is terminated
- AND status is updated to "stopped"
#### Scenario: Start tool
- GIVEN a stopped tool instance
- WHEN the user starts it
- THEN `docker compose start` is executed
- AND a new temporary Cloudflare tunnel is created
- AND status is updated to "running"
#### Scenario: Recreate tunnel
- GIVEN a running tool instance with a broken tunnel
- WHEN the user requests tunnel recreation
- THEN the existing cloudflared process is terminated
- AND a new temporary Cloudflare tunnel is created
- AND the instance URL is updated
- AND the instance shows as healthy
## ADDED Requirements
### Requirement: Tunnel Health Check
The system SHALL check tunnel health for running instances.
#### Scenario: Healthy tunnel check
- GIVEN a running instance with an active tunnel
- WHEN the health check runs
- THEN the tunnel URL responds with HTTP 2xx
- AND the instance is marked as healthy
#### Scenario: Broken tunnel check
- GIVEN a running instance with a broken tunnel
- WHEN the health check runs
- THEN the tunnel URL does not respond with HTTP 2xx
- AND the instance is marked with tunnel_error
- AND a "Recreate Tunnel" button is shown
@@ -0,0 +1,35 @@
## ADDED Requirements
### Requirement: System monitors tunnel health
The system SHALL periodically check if active tunnel URLs are reachable and mark them as erroneous if not.
#### Scenario: Healthy tunnel
- **WHEN** a tunnel health check is performed on a running instance
- **THEN** the system receives an HTTP 2xx response
- **AND** the instance status remains "running"
#### Scenario: Broken tunnel
- **WHEN** a tunnel health check is performed on a running instance
- **AND** the response is not HTTP 2xx or the request fails
- **THEN** the instance is marked with tunnel_error status
- **AND** a visual error indicator is displayed in the UI
### Requirement: Users can recreate broken tunnels
The system SHALL allow users to regenerate a temporary tunnel for a running instance without restarting the instance.
#### Scenario: Recreate tunnel
- **WHEN** user clicks "Recreate Tunnel" button on an instance with a broken tunnel
- **THEN** the system stops the existing cloudflared process
- **AND** starts a new cloudflared tunnel
- **AND** updates the instance URL
- **AND** the new URL is displayed in the UI
#### Scenario: Recreate tunnel success
- **WHEN** tunnel recreation completes successfully
- **THEN** the error indicator is removed
- **AND** the instance shows as healthy
#### Scenario: Recreate tunnel failure
- **WHEN** tunnel recreation fails
- **THEN** the error indicator remains
- **AND** an error message is displayed to the user