mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
55
apps/server/src/routes/terminal/routes/settings.ts
Normal file
55
apps/server/src/routes/terminal/routes/settings.ts
Normal 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),
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user