Skip to content

Commit f0b550e

Browse files
authored
Merge branch 'Acode-Foundation:main' into main
2 parents a843912 + 626c5fe commit f0b550e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+509
-152
lines changed

.github/workflows/close-inactive-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
2525
days-before-pr-stale: -1
2626
days-before-pr-close: -1
27-
exempt-issue-labels: "new plugin idea, todo"
27+
exempt-issue-labels: "new plugin idea, todo, enhancement, bug, Low priority, documentation"
2828
operations-per-run: 100
2929
repo-token: ${{ secrets.GITHUB_TOKEN }}
3030

src/components/terminal/terminalDefaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const DEFAULT_TERMINAL_SETTINGS = {
1414
letterSpacing: 0,
1515
imageSupport: false,
1616
fontLigatures: false,
17+
confirmTabClose: true,
1718
// Touch selection settings
1819
touchSelectionTapHoldDuration: 600,
1920
touchSelectionMoveThreshold: 8,

src/components/terminal/terminalManager.js

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import EditorFile from "lib/editorFile";
77
import TerminalComponent from "./terminal";
88
import "@xterm/xterm/css/xterm.css";
99
import toast from "components/toast";
10+
import confirm from "dialogs/confirm";
11+
import appSettings from "lib/settings";
1012
import helpers from "utils/helpers";
1113

1214
const TERMINAL_SESSION_STORAGE_KEY = "acodeTerminalSessions";
@@ -17,12 +19,15 @@ class TerminalManager {
1719
this.terminalCounter = 0;
1820
}
1921

20-
getPersistedSessions() {
22+
async getPersistedSessions() {
2123
try {
2224
const stored = helpers.parseJSON(
2325
localStorage.getItem(TERMINAL_SESSION_STORAGE_KEY),
2426
);
2527
if (!Array.isArray(stored)) return [];
28+
if (!(await Terminal.isAxsRunning())) {
29+
return [];
30+
}
2631
return stored
2732
.map((entry) => {
2833
if (!entry) return null;
@@ -56,11 +61,11 @@ class TerminalManager {
5661
}
5762
}
5863

59-
persistTerminalSession(pid, name) {
64+
async persistTerminalSession(pid, name) {
6065
if (!pid) return;
6166

6267
const pidStr = String(pid);
63-
const sessions = this.getPersistedSessions();
68+
const sessions = await this.getPersistedSessions();
6469
const existingIndex = sessions.findIndex(
6570
(session) => session.pid === pidStr,
6671
);
@@ -81,11 +86,11 @@ class TerminalManager {
8186
this.savePersistedSessions(sessions);
8287
}
8388

84-
removePersistedSession(pid) {
89+
async removePersistedSession(pid) {
8590
if (!pid) return;
8691

8792
const pidStr = String(pid);
88-
const sessions = this.getPersistedSessions();
93+
const sessions = await this.getPersistedSessions();
8994
const nextSessions = sessions.filter((session) => session.pid !== pidStr);
9095

9196
if (nextSessions.length !== sessions.length) {
@@ -94,7 +99,7 @@ class TerminalManager {
9499
}
95100

96101
async restorePersistedSessions() {
97-
const sessions = this.getPersistedSessions();
102+
const sessions = await this.getPersistedSessions();
98103
if (!sessions.length) return;
99104

100105
const manager = window.editorManager;
@@ -183,7 +188,7 @@ class TerminalManager {
183188
});
184189

185190
// Wait for tab creation and setup
186-
const terminalInstance = await new Promise((resolve, reject) => {
191+
return await new Promise((resolve, reject) => {
187192
setTimeout(async () => {
188193
try {
189194
// Mount terminal component
@@ -220,7 +225,10 @@ class TerminalManager {
220225
this.terminals.set(uniqueId, instance);
221226

222227
if (terminalComponent.serverMode && terminalComponent.pid) {
223-
this.persistTerminalSession(terminalComponent.pid, terminalName);
228+
await this.persistTerminalSession(
229+
terminalComponent.pid,
230+
terminalName,
231+
);
224232
}
225233
resolve(instance);
226234
} catch (error) {
@@ -229,8 +237,6 @@ class TerminalManager {
229237
}
230238
}, 100);
231239
});
232-
233-
return terminalInstance;
234240
} catch (error) {
235241
console.error("Failed to create terminal:", error);
236242
throw error;
@@ -334,7 +340,7 @@ class TerminalManager {
334340
});
335341

336342
// Wait for tab creation and setup
337-
const terminalInstance = await new Promise((resolve, reject) => {
343+
return await new Promise((resolve, reject) => {
338344
setTimeout(async () => {
339345
try {
340346
// Mount terminal component
@@ -374,8 +380,6 @@ class TerminalManager {
374380
}
375381
}, 100);
376382
});
377-
378-
return terminalInstance;
379383
}
380384

381385
/**
@@ -384,7 +388,7 @@ class TerminalManager {
384388
* @param {TerminalComponent} terminalComponent - Terminal component
385389
* @param {string} terminalId - Terminal ID
386390
*/
387-
setupTerminalHandlers(terminalFile, terminalComponent, terminalId) {
391+
async setupTerminalHandlers(terminalFile, terminalComponent, terminalId) {
388392
// Handle tab focus/blur
389393
terminalFile.onfocus = () => {
390394
// Guarded fit on focus: only fit if cols/rows would change, then focus
@@ -413,6 +417,22 @@ class TerminalManager {
413417
this.closeTerminal(terminalId);
414418
};
415419

420+
terminalFile._skipTerminalCloseConfirm = false;
421+
const originalRemove = terminalFile.remove.bind(terminalFile);
422+
terminalFile.remove = async (force = false) => {
423+
if (
424+
!terminalFile._skipTerminalCloseConfirm &&
425+
this.shouldConfirmTerminalClose()
426+
) {
427+
const message = `${strings["close"]} ${strings["terminal"]}?`;
428+
const shouldClose = await confirm(strings["confirm"], message);
429+
if (!shouldClose) return;
430+
}
431+
432+
terminalFile._skipTerminalCloseConfirm = false;
433+
return originalRemove(force);
434+
};
435+
416436
// Enhanced resize handling with debouncing
417437
let resizeTimeout = null;
418438
const RESIZE_DEBOUNCE = 200;
@@ -486,14 +506,17 @@ class TerminalManager {
486506
this.closeTerminal(terminalId);
487507
};
488508

489-
terminalComponent.onTitleChange = (title) => {
509+
terminalComponent.onTitleChange = async (title) => {
490510
if (title) {
491511
// Format terminal title as "Terminal ! - title"
492512
const formattedTitle = `Terminal ${this.terminalCounter} - ${title}`;
493513
terminalFile.filename = formattedTitle;
494514

495515
if (terminalComponent.serverMode && terminalComponent.pid) {
496-
this.persistTerminalSession(terminalComponent.pid, formattedTitle);
516+
await this.persistTerminalSession(
517+
terminalComponent.pid,
518+
formattedTitle,
519+
);
497520
}
498521

499522
// Refresh the header subtitle if this terminal is active
@@ -519,6 +542,7 @@ class TerminalManager {
519542
}
520543

521544
this.closeTerminal(terminalId);
545+
terminalFile._skipTerminalCloseConfirm = true;
522546
terminalFile.remove(true);
523547
toast(message);
524548
};
@@ -731,6 +755,14 @@ class TerminalManager {
731755
}
732756
});
733757
}
758+
759+
shouldConfirmTerminalClose() {
760+
const settings = appSettings?.value?.terminalSettings;
761+
if (settings && settings.confirmTabClose === false) {
762+
return false;
763+
}
764+
return true;
765+
}
734766
}
735767

736768
// Create singleton instance

src/lang/ar-ye.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@
418418
"terminal:cursor style": "شكل المؤشر",
419419
"terminal:font family": "عائلة الخطوط",
420420
"terminal:convert eol": "تحويل نهاية السطر",
421+
"terminal:confirm tab close": "Confirm terminal tab close",
422+
"terminal:image support": "Image support",
421423
"terminal": "الطرفية",
422424
"allFileAccess": "الوصول إلى جميع الملفات",
423425
"fonts": "الخطوط",

src/lang/be-by.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@
419419
"terminal:cursor style": "Cursor Style",
420420
"terminal:font family": "Font Family",
421421
"terminal:convert eol": "Convert EOL",
422+
"terminal:confirm tab close": "Confirm terminal tab close",
423+
"terminal:image support": "Image support",
422424
"terminal": "Terminal",
423425
"allFileAccess": "All file access",
424426
"fonts": "Fonts",

src/lang/bn-bd.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@
418418
"terminal:cursor style": "কার্সর স্টাইল",
419419
"terminal:font family": "ফন্ট ফ্যামিলি",
420420
"terminal:convert eol": "EOL রূপান্তর করুন",
421+
"terminal:confirm tab close": "Confirm terminal tab close",
422+
"terminal:image support": "Image support",
421423
"terminal": "টার্মিনাল",
422424
"allFileAccess": "সকল ফাইল অ্যাক্সেস",
423425
"fonts": "ফন্ট",

src/lang/cs-cz.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@
418418
"terminal:cursor style": "Cursor Style",
419419
"terminal:font family": "Font Family",
420420
"terminal:convert eol": "Convert EOL",
421+
"terminal:confirm tab close": "Confirm terminal tab close",
422+
"terminal:image support": "Image support",
421423
"terminal": "Terminal",
422424
"allFileAccess": "All file access",
423425
"fonts": "Fonts",

src/lang/de-de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@
418418
"terminal:cursor style": "Cursorstil",
419419
"terminal:font family": "Schriftfamilie",
420420
"terminal:convert eol": "Zeilenende konvertieren",
421+
"terminal:confirm tab close": "Terminal-Tab schließen bestätigen",
422+
"terminal:image support": "Bildunterstützung",
421423
"terminal": "Terminal",
422424
"allFileAccess": "Zugriff auf alle Dateien",
423425
"fonts": "Schriftarten",

src/lang/en-us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@
418418
"terminal:cursor style": "Cursor Style",
419419
"terminal:font family": "Font Family",
420420
"terminal:convert eol": "Convert EOL",
421+
"terminal:confirm tab close": "Confirm terminal tab close",
422+
"terminal:image support": "Image support",
421423
"terminal": "Terminal",
422424
"allFileAccess": "All file access",
423425
"fonts": "Fonts",

src/lang/es-sv.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@
418418
"terminal:cursor style": "Cursor Style",
419419
"terminal:font family": "Font Family",
420420
"terminal:convert eol": "Convert EOL",
421+
"terminal:confirm tab close": "Confirm terminal tab close",
422+
"terminal:image support": "Image support",
421423
"terminal": "Terminal",
422424
"allFileAccess": "All file access",
423425
"fonts": "Fonts",

0 commit comments

Comments
 (0)