feat: add session rename and delete functionality with validation
- Introduced `SessionRename` model for renaming sessions with validation on name length and content. - Implemented `rename_session` endpoint in `session_routes.py` to handle session renaming. - Added `delete_session` endpoint to remove sessions, ensuring proper cleanup of associated data. - Enhanced `SessionStore` with `rename` and `delete` methods, including validation and transaction management. - Updated `SessionManager` to manage session renaming and deletion, ensuring live terminal state is preserved. - Added tests for renaming and deleting sessions, ensuring proper functionality and validation. - Introduced a new `tool_catalog.py` for managing guest tool selections and installation recipes.
This commit is contained in:
+18
-4
@@ -909,6 +909,8 @@ Nest. Both server entry points expose the UVM management routes below.
|
||||
| `GET` | `/vms/{vm_id}/sessions` | `nest/session_routes.py` | Saved session list (Nest only) |
|
||||
| `POST` | `/vms/{vm_id}/sessions` | `nest/session_routes.py` | Launch a guest PTY; optional rows/cols in a JSON object (Nest only) |
|
||||
| `GET` | `/vms/{vm_id}/sessions/{session_id}` | `nest/session_routes.py` | VM-scoped session metadata (Nest only) |
|
||||
| `PATCH` | `/vms/{vm_id}/sessions/{session_id}` | `nest/session_routes.py` | Rename via a strict `name` body; identity retained (Nest only) |
|
||||
| `DELETE` | `/vms/{vm_id}/sessions/{session_id}` | `nest/session_routes.py` | Close channel, join output reader, delete history; 204 (Nest only) |
|
||||
| `POST` | `/vms/{vm_id}/sessions/{session_id}/close` | `nest/session_routes.py` | End a shell; retain history (Nest only) |
|
||||
| `WS` | `/vms/{vm_id}/sessions/{session_id}/terminal` | `nest/session_routes.py` | Authenticated replay/input/resize (Nest only) |
|
||||
|
||||
@@ -1051,8 +1053,12 @@ window-size changes are handled by the guest terminal driver. Normal exit,
|
||||
explicit close, or host connection loss cleans up the job cgroup and processes.
|
||||
|
||||
`SessionManager` owns background output readers independently of WebSocket
|
||||
attachments. Creating a shell is shielded from an HTTP disconnect; its connection
|
||||
is either tracked or closed. Browser navigation, reload, and logout detach only
|
||||
attachments. Accepted creation, rename, close, and delete operations are tracked
|
||||
and shielded from HTTP disconnects. Creation and termination share a session
|
||||
lock, so deleting a starting session waits for its channel to be tracked and
|
||||
then closes it. Deletion joins the output reader and its pending writes before
|
||||
atomically removing the metadata and transcript rows. Browser navigation,
|
||||
reload, and logout detach only
|
||||
the browser. Nest shutdown closes guest connections and marks live sessions
|
||||
interrupted. In-flight transcript writes finish before releasing store ownership.
|
||||
|
||||
@@ -1062,7 +1068,11 @@ directory, mode-0600 files, an exclusive owner lock, and SQLite transactions
|
||||
protect history. On reopening after a server restart, unfinished records become
|
||||
interrupted. Session lookups always include the exact VM ID. Output is capped at
|
||||
the newest 8 MiB per session with byte offsets and an explicit truncation marker;
|
||||
session metadata is retained. Only PTY output is recorded, not a separate input
|
||||
session metadata is retained until explicit deletion. Session names are trimmed,
|
||||
1–80 printable characters, and are display labels rather than identifiers.
|
||||
Renaming updates only the name and modification time; generated default names
|
||||
avoid labels still present after renames or deletions. Only PTY output is
|
||||
recorded, not a separate input
|
||||
or password log. Nest permits 32 active sessions; guest terminals share the
|
||||
agent's eight connection slots with one-shot jobs.
|
||||
|
||||
@@ -1074,6 +1084,9 @@ offset after xterm renders the chunk. Only one chunk is outstanding, providing
|
||||
backpressure. Reattachment resumes from an acknowledged offset; a truncated
|
||||
prefix resets the viewer. Closed sessions use the same channel for read-only
|
||||
replay. WebSocket transport support comes from the `websockets` dependency.
|
||||
Renames notify attached viewers through updated session metadata. A deleted
|
||||
session sends a `deleted` event to authenticated attachments; polling also clears
|
||||
stale selections for completed sessions whose replay connection already closed.
|
||||
|
||||
The dashboard's Sessions tab and nested hash routes belong to the selected VM.
|
||||
`sessions.js` owns attachment teardown, replay, reconnects, and the terminal
|
||||
@@ -1182,7 +1195,8 @@ NODE_PATH=/tmp/nest-browser/node_modules \
|
||||
```
|
||||
|
||||
This checks launch/input, reload/reconnect, session switching, per-VM isolation,
|
||||
closed-session replay, and the mobile layout. It does not boot a real microVM.
|
||||
closed-session replay, rename persistence, active/ended deletion, cancellation,
|
||||
multi-tab updates, and the mobile layout. It does not boot a real microVM.
|
||||
|
||||
When `nft` and `conntrack` are installed, command-parser tests append an invalid
|
||||
final command/option so parsing is checked without executing any mutation.
|
||||
|
||||
Reference in New Issue
Block a user