mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
refactor: update terminal session limits and improve layout saving
- Refactored session limit checks in terminal settings to use constants for minimum and maximum session values. - Enhanced terminal layout saving mechanism with debouncing to prevent excessive writes during rapid changes. - Updated error messages to reflect new session limit constants.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import type { Request, Response } from "express";
|
||||
import { getTerminalService } from "../../../services/terminal-service.js";
|
||||
import { getTerminalService, MIN_MAX_SESSIONS, MAX_MAX_SESSIONS } from "../../../services/terminal-service.js";
|
||||
import { getErrorMessage, logError } from "../common.js";
|
||||
|
||||
export function createSettingsGetHandler() {
|
||||
@@ -26,10 +26,10 @@ export function createSettingsUpdateHandler() {
|
||||
const { maxSessions } = req.body;
|
||||
|
||||
if (typeof maxSessions === "number") {
|
||||
if (maxSessions < 1 || maxSessions > 500) {
|
||||
if (maxSessions < MIN_MAX_SESSIONS || maxSessions > MAX_MAX_SESSIONS) {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: "maxSessions must be between 1 and 500",
|
||||
error: `maxSessions must be between ${MIN_MAX_SESSIONS} and ${MAX_MAX_SESSIONS}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ import * as fs from "fs";
|
||||
// Maximum scrollback buffer size (characters)
|
||||
const MAX_SCROLLBACK_SIZE = 50000; // ~50KB per terminal
|
||||
|
||||
// Session limit constants - shared with routes/settings.ts
|
||||
export const MIN_MAX_SESSIONS = 1;
|
||||
export const MAX_MAX_SESSIONS = 500;
|
||||
|
||||
// Maximum number of concurrent terminal sessions
|
||||
// Can be overridden via TERMINAL_MAX_SESSIONS environment variable
|
||||
// Default set to 1000 - effectively unlimited for most use cases
|
||||
@@ -200,7 +204,7 @@ export class TerminalService extends EventEmitter {
|
||||
* Set maximum allowed sessions (can be called dynamically)
|
||||
*/
|
||||
setMaxSessions(limit: number): void {
|
||||
if (limit >= 1 && limit <= 500) {
|
||||
if (limit >= MIN_MAX_SESSIONS && limit <= MAX_MAX_SESSIONS) {
|
||||
maxSessions = limit;
|
||||
console.log(`[Terminal] Max sessions limit updated to ${limit}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user