Skip to content

Commit 2d96fb2

Browse files
authored
Merge branch 'Acode-Foundation:main' into codemirror
2 parents eab85e6 + 2e2e93c commit 2d96fb2

File tree

4 files changed

+269
-45
lines changed

4 files changed

+269
-45
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/terminalManager.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ class TerminalManager {
1919
this.terminalCounter = 0;
2020
}
2121

22-
getPersistedSessions() {
22+
async getPersistedSessions() {
2323
try {
2424
const stored = helpers.parseJSON(
2525
localStorage.getItem(TERMINAL_SESSION_STORAGE_KEY),
2626
);
2727
if (!Array.isArray(stored)) return [];
28+
if (!(await Terminal.isAxsRunning())) {
29+
return [];
30+
}
2831
return stored
2932
.map((entry) => {
3033
if (!entry) return null;
@@ -58,11 +61,11 @@ class TerminalManager {
5861
}
5962
}
6063

61-
persistTerminalSession(pid, name) {
64+
async persistTerminalSession(pid, name) {
6265
if (!pid) return;
6366

6467
const pidStr = String(pid);
65-
const sessions = this.getPersistedSessions();
68+
const sessions = await this.getPersistedSessions();
6669
const existingIndex = sessions.findIndex(
6770
(session) => session.pid === pidStr,
6871
);
@@ -83,11 +86,11 @@ class TerminalManager {
8386
this.savePersistedSessions(sessions);
8487
}
8588

86-
removePersistedSession(pid) {
89+
async removePersistedSession(pid) {
8790
if (!pid) return;
8891

8992
const pidStr = String(pid);
90-
const sessions = this.getPersistedSessions();
93+
const sessions = await this.getPersistedSessions();
9194
const nextSessions = sessions.filter((session) => session.pid !== pidStr);
9295

9396
if (nextSessions.length !== sessions.length) {
@@ -96,7 +99,7 @@ class TerminalManager {
9699
}
97100

98101
async restorePersistedSessions() {
99-
const sessions = this.getPersistedSessions();
102+
const sessions = await this.getPersistedSessions();
100103
if (!sessions.length) return;
101104

102105
const manager = window.editorManager;
@@ -185,7 +188,7 @@ class TerminalManager {
185188
});
186189

187190
// Wait for tab creation and setup
188-
const terminalInstance = await new Promise((resolve, reject) => {
191+
return await new Promise((resolve, reject) => {
189192
setTimeout(async () => {
190193
try {
191194
// Mount terminal component
@@ -222,7 +225,10 @@ class TerminalManager {
222225
this.terminals.set(uniqueId, instance);
223226

224227
if (terminalComponent.serverMode && terminalComponent.pid) {
225-
this.persistTerminalSession(terminalComponent.pid, terminalName);
228+
await this.persistTerminalSession(
229+
terminalComponent.pid,
230+
terminalName,
231+
);
226232
}
227233
resolve(instance);
228234
} catch (error) {
@@ -231,8 +237,6 @@ class TerminalManager {
231237
}
232238
}, 100);
233239
});
234-
235-
return terminalInstance;
236240
} catch (error) {
237241
console.error("Failed to create terminal:", error);
238242
throw error;
@@ -336,7 +340,7 @@ class TerminalManager {
336340
});
337341

338342
// Wait for tab creation and setup
339-
const terminalInstance = await new Promise((resolve, reject) => {
343+
return await new Promise((resolve, reject) => {
340344
setTimeout(async () => {
341345
try {
342346
// Mount terminal component
@@ -376,8 +380,6 @@ class TerminalManager {
376380
}
377381
}, 100);
378382
});
379-
380-
return terminalInstance;
381383
}
382384

383385
/**
@@ -386,7 +388,7 @@ class TerminalManager {
386388
* @param {TerminalComponent} terminalComponent - Terminal component
387389
* @param {string} terminalId - Terminal ID
388390
*/
389-
setupTerminalHandlers(terminalFile, terminalComponent, terminalId) {
391+
async setupTerminalHandlers(terminalFile, terminalComponent, terminalId) {
390392
// Handle tab focus/blur
391393
terminalFile.onfocus = () => {
392394
// Guarded fit on focus: only fit if cols/rows would change, then focus
@@ -504,14 +506,17 @@ class TerminalManager {
504506
this.closeTerminal(terminalId);
505507
};
506508

507-
terminalComponent.onTitleChange = (title) => {
509+
terminalComponent.onTitleChange = async (title) => {
508510
if (title) {
509511
// Format terminal title as "Terminal ! - title"
510512
const formattedTitle = `Terminal ${this.terminalCounter} - ${title}`;
511513
terminalFile.filename = formattedTitle;
512514

513515
if (terminalComponent.serverMode && terminalComponent.pid) {
514-
this.persistTerminalSession(terminalComponent.pid, formattedTitle);
516+
await this.persistTerminalSession(
517+
terminalComponent.pid,
518+
formattedTitle,
519+
);
515520
}
516521

517522
// Refresh the header subtitle if this terminal is active

src/pages/fileBrowser/fileBrowser.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,20 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
748748
});
749749
}
750750

751+
async function getShareableUri(fileUrl) {
752+
if (!fileUrl) return null;
753+
try {
754+
const fs = fsOperation(fileUrl);
755+
if (/^s?ftp:/.test(fileUrl)) {
756+
return fs.localName;
757+
}
758+
const stat = await fs.stat();
759+
return stat?.url || null;
760+
} catch (error) {
761+
return null;
762+
}
763+
}
764+
751765
async function contextMenuHandler() {
752766
if (appSettings.value.vibrateOnTap) {
753767
navigator.vibrate(constants.VIBRATION_TIME);
@@ -824,19 +838,20 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
824838

825839
case "open_with":
826840
try {
827-
let mimeType = mimeTypes.lookup(name || "text/plain");
828-
const fs = fsOperation(url);
829-
if (/^s?ftp:/.test(url)) return fs.localName;
830-
831-
system.fileAction(
832-
(await fs.stat()).url,
833-
name,
834-
"VIEW",
835-
mimeType,
836-
() => {
837-
toast(strings["no app found to handle this file"]);
838-
},
839-
);
841+
const shareableUri = await getShareableUri(url);
842+
if (!shareableUri) {
843+
toast(strings["no app found to handle this file"]);
844+
break;
845+
}
846+
847+
const mimeType =
848+
mimeTypes.lookup(name) ||
849+
mimeTypes.lookup(shareableUri) ||
850+
"text/plain";
851+
852+
system.fileAction(shareableUri, name, "VIEW", mimeType, () => {
853+
toast(strings["no app found to handle this file"]);
854+
});
840855
} catch (error) {
841856
console.error(error);
842857
toast(strings.error);

0 commit comments

Comments
 (0)