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:
@@ -627,12 +627,26 @@ export function TerminalView() {
|
||||
}
|
||||
}, [currentProject?.path, saveTerminalLayout, getPersistedTerminalLayout, clearTerminalState, addTerminalTab, serverUrl]);
|
||||
|
||||
// Save terminal layout whenever it changes (debounced via the effect)
|
||||
// Save terminal layout whenever it changes (debounced to prevent excessive writes)
|
||||
// Also save when tabs become empty so closed terminals stay closed on refresh
|
||||
const saveLayoutTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
useEffect(() => {
|
||||
if (currentProject?.path && !isRestoringLayoutRef.current) {
|
||||
saveTerminalLayout(currentProject.path);
|
||||
// Debounce saves to prevent excessive localStorage writes during rapid changes
|
||||
if (saveLayoutTimeoutRef.current) {
|
||||
clearTimeout(saveLayoutTimeoutRef.current);
|
||||
}
|
||||
saveLayoutTimeoutRef.current = setTimeout(() => {
|
||||
saveTerminalLayout(currentProject.path);
|
||||
saveLayoutTimeoutRef.current = null;
|
||||
}, 500); // 500ms debounce
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (saveLayoutTimeoutRef.current) {
|
||||
clearTimeout(saveLayoutTimeoutRef.current);
|
||||
}
|
||||
};
|
||||
}, [terminalState.tabs, currentProject?.path, saveTerminalLayout]);
|
||||
|
||||
// Handle password authentication
|
||||
|
||||
Reference in New Issue
Block a user