feat: enhance terminal functionality and settings

- Added new endpoints for terminal settings: GET and PUT /settings to retrieve and update terminal configurations.
- Implemented session limit checks during session creation, returning a 429 status when the limit is reached.
- Introduced a new TerminalSection in settings view for customizing terminal appearance and behavior, including font family, default font size, line height, and screen reader mode.
- Added support for new terminal features such as search functionality and improved error handling with a TerminalErrorBoundary component.
- Updated terminal layout persistence to include session IDs for reconnection and enhanced terminal state management.
- Introduced new keyboard shortcuts for terminal actions, including creating new terminal tabs.
- Enhanced UI with scrollbar theming for terminal components.
This commit is contained in:
SuperComboGamer
2025-12-20 22:56:25 -05:00
parent 8fcc6cb4db
commit 195b98e688
24 changed files with 2729 additions and 149 deletions

View File

@@ -21,6 +21,10 @@ import {
} from "./routes/sessions.js";
import { createSessionDeleteHandler } from "./routes/session-delete.js";
import { createSessionResizeHandler } from "./routes/session-resize.js";
import {
createSettingsGetHandler,
createSettingsUpdateHandler,
} from "./routes/settings.js";
// Re-export for use in main index.ts
export { validateTerminalToken, isTerminalEnabled, isTerminalPasswordRequired };
@@ -39,6 +43,8 @@ export function createTerminalRoutes(): Router {
router.post("/sessions", createSessionsCreateHandler());
router.delete("/sessions/:id", createSessionDeleteHandler());
router.post("/sessions/:id/resize", createSessionResizeHandler());
router.get("/settings", createSettingsGetHandler());
router.put("/settings", createSettingsUpdateHandler());
return router;
}

View File

@@ -34,6 +34,21 @@ export function createSessionsCreateHandler() {
shell,
});
// Check if session creation was refused due to limit
if (!session) {
const maxSessions = terminalService.getMaxSessions();
const currentSessions = terminalService.getSessionCount();
logger.warn(`Session limit reached: ${currentSessions}/${maxSessions}`);
res.status(429).json({
success: false,
error: "Maximum terminal sessions reached",
details: `Server limit is ${maxSessions} concurrent sessions. Please close unused terminals.`,
currentSessions,
maxSessions,
});
return;
}
res.json({
success: true,
data: {

View File

@@ -0,0 +1,55 @@
/**
* GET/PUT /settings endpoint - Get/Update terminal settings
*/
import type { Request, Response } from "express";
import { getTerminalService } from "../../../services/terminal-service.js";
import { getErrorMessage, logError } from "../common.js";
export function createSettingsGetHandler() {
return (_req: Request, res: Response): void => {
const terminalService = getTerminalService();
res.json({
success: true,
data: {
maxSessions: terminalService.getMaxSessions(),
currentSessions: terminalService.getSessionCount(),
},
});
};
}
export function createSettingsUpdateHandler() {
return (req: Request, res: Response): void => {
try {
const terminalService = getTerminalService();
const { maxSessions } = req.body;
if (typeof maxSessions === "number") {
if (maxSessions < 1 || maxSessions > 500) {
res.status(400).json({
success: false,
error: "maxSessions must be between 1 and 500",
});
return;
}
terminalService.setMaxSessions(maxSessions);
}
res.json({
success: true,
data: {
maxSessions: terminalService.getMaxSessions(),
currentSessions: terminalService.getSessionCount(),
},
});
} catch (error) {
logError(error, "Update terminal settings failed");
res.status(500).json({
success: false,
error: "Failed to update terminal settings",
details: getErrorMessage(error),
});
}
};
}