@innovatorved/code-lab 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +1 -1
- package/CHANGELOG.md +15 -0
- package/README.md +38 -1
- package/dist/code-lab-sql.esm.js +1 -1
- package/dist/code-lab-sql.umd.js +2 -2
- package/dist/code-lab.css +1 -1
- package/dist/code-lab.d.ts +19 -1
- package/dist/code-lab.esm.js +712 -704
- package/dist/code-lab.js +711 -703
- package/dist/code-lab.umd.js +711 -703
- package/dist/extensions/cpp.esm.js +9 -0
- package/dist/extensions/cpp.js +9 -0
- package/dist/extensions/guided-lab.esm.js +9 -0
- package/dist/extensions/guided-lab.js +9 -0
- package/dist/extensions/python.esm.js +9 -0
- package/dist/extensions/python.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/preview-sw.js +1 -1
- package/dist/runtime.esm.js +70 -70
- package/dist/runtime.js +70 -70
- package/dist/schemas.d.ts +13 -1
- package/dist/schemas.esm.js +9 -0
- package/dist/schemas.js +9 -0
- package/dist/shell.esm.js +250 -244
- package/dist/shell.js +250 -244
- package/dist/terminal.esm.js +1 -1
- package/dist/terminal.js +1 -1
- package/package.json +1 -1
- package/packages/commands/package.json +1 -1
- package/packages/core/package.json +1 -1
- package/packages/editor/package.json +1 -1
- package/packages/fs/package.json +1 -1
- package/packages/preview/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/settings/package.json +1 -1
- package/packages/settings/src/builtin-schemas.ts +16 -0
- package/packages/sql/package.json +1 -1
- package/packages/terminal/package.json +1 -1
- package/packages/ui/package.json +1 -1
- package/packages/ui/src/settings-dialog.ts +30 -2
- package/src/code-lab.css +7 -1
- package/src/index.ts +1 -1
- package/src/runtime.ts +29 -3
- package/src/schemas.ts +10 -1
- package/src/shell.ts +106 -16
- package/src/workbench.ts +365 -82
package/src/workbench.ts
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
|
|
84
84
|
// The bundler rewrites this literal from package.json at build time. Keeping
|
|
85
85
|
// the fallback in sync lets tests require src/workbench.js directly.
|
|
86
|
-
const CODELAB_VERSION = '0.
|
|
86
|
+
const CODELAB_VERSION = '0.7.0';
|
|
87
87
|
|
|
88
88
|
// Ambient TypeScript declarations for Node.js built-ins inside Monaco
|
|
89
89
|
const NODE_AMBIENT_DTS = `
|
|
@@ -2107,10 +2107,20 @@ int main() {
|
|
|
2107
2107
|
}
|
|
2108
2108
|
|
|
2109
2109
|
// Load persisted user settings from localStorage if available
|
|
2110
|
+
const persistedUserKeys = new Set();
|
|
2110
2111
|
if (this.persistState && this.configuration) {
|
|
2111
2112
|
const savedUserSettings = safeStorageGet(`${STORAGE_PREFIX}user-settings`, this.logger);
|
|
2112
2113
|
if (savedUserSettings) {
|
|
2113
2114
|
this.configuration.importProfile(savedUserSettings);
|
|
2115
|
+
try {
|
|
2116
|
+
const parsedSaved = JSON.parse(savedUserSettings);
|
|
2117
|
+
const savedObj = parsedSaved && typeof parsedSaved.user === 'object' ? parsedSaved.user : parsedSaved;
|
|
2118
|
+
if (savedObj && typeof savedObj === 'object') {
|
|
2119
|
+
for (const k of Object.keys(savedObj)) persistedUserKeys.add(k);
|
|
2120
|
+
}
|
|
2121
|
+
} catch (_err) {
|
|
2122
|
+
void _err;
|
|
2123
|
+
}
|
|
2114
2124
|
}
|
|
2115
2125
|
}
|
|
2116
2126
|
|
|
@@ -2127,9 +2137,35 @@ int main() {
|
|
|
2127
2137
|
}
|
|
2128
2138
|
}
|
|
2129
2139
|
|
|
2130
|
-
// Apply
|
|
2131
|
-
|
|
2132
|
-
|
|
2140
|
+
// Apply host-provided initial settings/config cleanly:
|
|
2141
|
+
// - `options.userSettings` / `options.defaultSettings` (and `options.settings` / `options.config`
|
|
2142
|
+
// when `options.lockSettings !== true`) seed Layer 2 user settings so host apps can customize
|
|
2143
|
+
// defaults while end-users can still adjust them in the Settings UI.
|
|
2144
|
+
// - `options.overrides` (or `options.settings` with `options.lockSettings === true`) lock Layer 4.
|
|
2145
|
+
if (this.options && this.configuration) {
|
|
2146
|
+
const seedSources = [
|
|
2147
|
+
this.options.defaultSettings,
|
|
2148
|
+
this.options.userSettings,
|
|
2149
|
+
this.options.config,
|
|
2150
|
+
this.options.lockSettings === true ? null : this.options.settings
|
|
2151
|
+
];
|
|
2152
|
+
for (const src of seedSources) {
|
|
2153
|
+
if (!src || typeof src !== 'object') continue;
|
|
2154
|
+
for (const [k, v] of Object.entries(src)) {
|
|
2155
|
+
if (!this.persistState || !persistedUserKeys.has(k)) {
|
|
2156
|
+
this.configuration.setUserSetting(k, v);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
const lockedOverrides = {
|
|
2161
|
+
...(this.options.lockSettings === true && this.options.settings && typeof this.options.settings === 'object'
|
|
2162
|
+
? this.options.settings
|
|
2163
|
+
: {}),
|
|
2164
|
+
...(this.options.overrides && typeof this.options.overrides === 'object' ? this.options.overrides : {})
|
|
2165
|
+
};
|
|
2166
|
+
if (Object.keys(lockedOverrides).length > 0) {
|
|
2167
|
+
this.configuration.setOverrides(lockedOverrides);
|
|
2168
|
+
}
|
|
2133
2169
|
}
|
|
2134
2170
|
|
|
2135
2171
|
// Register built-in commands & keybindings
|
|
@@ -3523,38 +3559,35 @@ int main() {
|
|
|
3523
3559
|
}
|
|
3524
3560
|
}
|
|
3525
3561
|
}
|
|
3526
|
-
|
|
3527
|
-
this.
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
this._syncFilesToShellVfs();
|
|
3531
|
-
}
|
|
3532
|
-
if (!this._savedSnapshot) this._savedSnapshot = {};
|
|
3533
|
-
const autoSaveMode = this.configuration
|
|
3534
|
-
? this.configuration.get('files.autoSave', 'afterDelay')
|
|
3535
|
-
: 'afterDelay';
|
|
3536
|
-
if (saveAll || !targetFile || (autoSaveMode !== 'off' && autoSaveMode !== 'onFocusChange')) {
|
|
3537
|
-
this._savedSnapshot = { ...(this.files || {}) };
|
|
3538
|
-
this._clearFileDirty();
|
|
3539
|
-
this._saveState({ flushFiles: true });
|
|
3540
|
-
} else {
|
|
3541
|
-
if (this.files[targetFile] !== undefined) {
|
|
3542
|
-
this._savedSnapshot[targetFile] = this.files[targetFile];
|
|
3562
|
+
const finalizeSave = () => {
|
|
3563
|
+
if (targetFile && this.files[targetFile] !== undefined) {
|
|
3564
|
+
this._syncDotCodelabConfig();
|
|
3565
|
+
this._vfsWriteFile(targetFile, this.files[targetFile]);
|
|
3543
3566
|
} else {
|
|
3544
|
-
|
|
3567
|
+
this._syncFilesToShellVfs();
|
|
3545
3568
|
}
|
|
3546
|
-
this.
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3569
|
+
if (!this._savedSnapshot) this._savedSnapshot = {};
|
|
3570
|
+
const autoSaveMode = this.configuration
|
|
3571
|
+
? this.configuration.get('files.autoSave', 'afterDelay')
|
|
3572
|
+
: 'afterDelay';
|
|
3573
|
+
if (saveAll || !targetFile || (autoSaveMode !== 'off' && autoSaveMode !== 'onFocusChange')) {
|
|
3574
|
+
this._savedSnapshot = { ...(this.files || {}) };
|
|
3575
|
+
this._clearFileDirty();
|
|
3576
|
+
this._saveState({ flushFiles: true });
|
|
3577
|
+
} else {
|
|
3578
|
+
if (this.files[targetFile] !== undefined) {
|
|
3579
|
+
this._savedSnapshot[targetFile] = this.files[targetFile];
|
|
3580
|
+
} else {
|
|
3581
|
+
delete this._savedSnapshot[targetFile];
|
|
3555
3582
|
}
|
|
3556
|
-
this._clearFileDirty(
|
|
3583
|
+
this._clearFileDirty(targetFile);
|
|
3557
3584
|
this._saveState({ flushSnapshotOnly: true });
|
|
3585
|
+
}
|
|
3586
|
+
};
|
|
3587
|
+
finalizeSave();
|
|
3588
|
+
if (formatPromise && typeof formatPromise.then === 'function') {
|
|
3589
|
+
formatPromise.then(() => {
|
|
3590
|
+
if (!this._destroyed) finalizeSave();
|
|
3558
3591
|
}).catch((err) => {
|
|
3559
3592
|
this.logger.debug('Async formatOnSave completion skipped.', err);
|
|
3560
3593
|
});
|
|
@@ -4297,6 +4330,17 @@ int main() {
|
|
|
4297
4330
|
this.container.querySelectorAll('[data-cl-action="run-code"], [data-cl-action="run-entry"], [data-cl-action="run-active-file"], [data-cl-action="run-demo"], [data-cl-action="run-tests"], [data-cl-action="verify-step"]').forEach(btn => {
|
|
4298
4331
|
btn.disabled = this.isRunning;
|
|
4299
4332
|
});
|
|
4333
|
+
if (this._xtermEngines instanceof Map && Array.isArray(this._terminalSessions)) {
|
|
4334
|
+
for (const sess of this._terminalSessions) {
|
|
4335
|
+
const eng = this._xtermEngines.get(sess.id);
|
|
4336
|
+
if (eng && typeof eng.setBusy === 'function') {
|
|
4337
|
+
const sessBusy = sess.id === this._activeTerminalSessionId
|
|
4338
|
+
? Boolean(sess.isRunning || this.isRunning)
|
|
4339
|
+
: Boolean(sess.isRunning);
|
|
4340
|
+
eng.setBusy(sessBusy);
|
|
4341
|
+
}
|
|
4342
|
+
}
|
|
4343
|
+
}
|
|
4300
4344
|
this._updatePtyActiveLine();
|
|
4301
4345
|
}
|
|
4302
4346
|
|
|
@@ -5741,11 +5785,16 @@ int main() {
|
|
|
5741
5785
|
});
|
|
5742
5786
|
});
|
|
5743
5787
|
|
|
5788
|
+
const isExternalFilesDrag = (ev) =>
|
|
5789
|
+
Boolean(ev.dataTransfer && ev.dataTransfer.types && Array.from(ev.dataTransfer.types).includes('Files'));
|
|
5790
|
+
|
|
5744
5791
|
// Attach folder drop events
|
|
5745
5792
|
explorerEl.querySelectorAll('.codelab-folder-item').forEach(el => {
|
|
5746
5793
|
el.addEventListener('dragover', ev => {
|
|
5747
5794
|
ev.preventDefault();
|
|
5748
|
-
if (ev.dataTransfer)
|
|
5795
|
+
if (ev.dataTransfer) {
|
|
5796
|
+
ev.dataTransfer.dropEffect = isExternalFilesDrag(ev) ? 'copy' : 'move';
|
|
5797
|
+
}
|
|
5749
5798
|
el.classList.add('drag-over');
|
|
5750
5799
|
});
|
|
5751
5800
|
el.addEventListener('dragleave', () => {
|
|
@@ -5755,23 +5804,42 @@ int main() {
|
|
|
5755
5804
|
ev.preventDefault();
|
|
5756
5805
|
ev.stopPropagation();
|
|
5757
5806
|
el.classList.remove('drag-over');
|
|
5807
|
+
explorerEl.classList.remove('drag-over');
|
|
5808
|
+
const folder = el.dataset.clFolder || '';
|
|
5809
|
+
if (ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files.length > 0) {
|
|
5810
|
+
this.importDroppedFiles(ev.dataTransfer.files, folder);
|
|
5811
|
+
return;
|
|
5812
|
+
}
|
|
5758
5813
|
const fileToMove = this._draggedFile || (ev.dataTransfer && ev.dataTransfer.getData('text/plain'));
|
|
5759
|
-
|
|
5760
|
-
if (fileToMove && folder !== undefined) {
|
|
5814
|
+
if (fileToMove && el.dataset.clFolder !== undefined) {
|
|
5761
5815
|
this.moveFile(fileToMove, folder);
|
|
5762
5816
|
}
|
|
5763
5817
|
});
|
|
5764
5818
|
});
|
|
5765
5819
|
|
|
5766
|
-
// Explorer container drop target (for moving to workspace root)
|
|
5820
|
+
// Explorer container drop target (for moving to workspace root or importing OS files)
|
|
5767
5821
|
if (!explorerEl._dragBound) {
|
|
5768
5822
|
explorerEl._dragBound = true;
|
|
5769
5823
|
explorerEl.addEventListener('dragover', ev => {
|
|
5770
5824
|
ev.preventDefault();
|
|
5825
|
+
if (ev.dataTransfer && isExternalFilesDrag(ev)) {
|
|
5826
|
+
ev.dataTransfer.dropEffect = 'copy';
|
|
5827
|
+
explorerEl.classList.add('drag-over');
|
|
5828
|
+
}
|
|
5829
|
+
});
|
|
5830
|
+
explorerEl.addEventListener('dragleave', ev => {
|
|
5831
|
+
if (!ev.relatedTarget || !explorerEl.contains(ev.relatedTarget)) {
|
|
5832
|
+
explorerEl.classList.remove('drag-over');
|
|
5833
|
+
}
|
|
5771
5834
|
});
|
|
5772
5835
|
explorerEl.addEventListener('drop', ev => {
|
|
5836
|
+
explorerEl.classList.remove('drag-over');
|
|
5773
5837
|
if (ev.target.closest && ev.target.closest('.codelab-folder-item')) return;
|
|
5774
5838
|
ev.preventDefault();
|
|
5839
|
+
if (ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files.length > 0) {
|
|
5840
|
+
this.importDroppedFiles(ev.dataTransfer.files, '');
|
|
5841
|
+
return;
|
|
5842
|
+
}
|
|
5775
5843
|
const fileToMove = this._draggedFile || (ev.dataTransfer && ev.dataTransfer.getData('text/plain'));
|
|
5776
5844
|
if (fileToMove) {
|
|
5777
5845
|
this.moveFile(fileToMove, '');
|
|
@@ -7398,18 +7466,34 @@ int main() {
|
|
|
7398
7466
|
}
|
|
7399
7467
|
}
|
|
7400
7468
|
|
|
7401
|
-
|
|
7469
|
+
_getTerminalSessionById(sessionId) {
|
|
7470
|
+
const sessions = this._ensureTerminalSessions();
|
|
7471
|
+
if (sessionId) {
|
|
7472
|
+
return sessions.find((s) => s.id === sessionId) || null;
|
|
7473
|
+
}
|
|
7474
|
+
return sessions.find((s) => s.id === this._activeTerminalSessionId) || sessions[0] || null;
|
|
7475
|
+
}
|
|
7476
|
+
|
|
7477
|
+
_getXtermEngineForSessionId(sessionId) {
|
|
7478
|
+
if (!(this._xtermEngines instanceof Map)) return null;
|
|
7479
|
+
if (sessionId) return this._xtermEngines.get(sessionId) || null;
|
|
7480
|
+
return this._getActiveXtermEngine();
|
|
7481
|
+
}
|
|
7482
|
+
|
|
7483
|
+
_appendTerminalStream(type = 'stdout', chunk = '', sessionId = null) {
|
|
7402
7484
|
if (chunk === null || chunk === undefined || chunk === '') return;
|
|
7403
7485
|
const rawText = String(chunk);
|
|
7486
|
+
const targetSessionId = sessionId || this._activeTerminalSessionId || null;
|
|
7487
|
+
const isTargetActive = !targetSessionId || targetSessionId === this._activeTerminalSessionId;
|
|
7404
7488
|
|
|
7405
|
-
const
|
|
7406
|
-
if (
|
|
7489
|
+
const targetXterm = this._getXtermEngineForSessionId(targetSessionId);
|
|
7490
|
+
if (targetXterm && typeof targetXterm.writeStreamChunk === 'function') {
|
|
7407
7491
|
try {
|
|
7408
|
-
|
|
7492
|
+
targetXterm.writeStreamChunk(rawText, type);
|
|
7409
7493
|
} catch (err) {
|
|
7410
|
-
this.logger.debug('
|
|
7494
|
+
this.logger.debug('targetXterm.writeStreamChunk failed.', err);
|
|
7411
7495
|
}
|
|
7412
|
-
} else if (this.ptyEngine && this.ptyEngine.container && typeof this.ptyEngine.writeStreamChunk === 'function') {
|
|
7496
|
+
} else if (isTargetActive && this.ptyEngine && this.ptyEngine.container && typeof this.ptyEngine.writeStreamChunk === 'function') {
|
|
7413
7497
|
try {
|
|
7414
7498
|
this.ptyEngine.writeStreamChunk(rawText, type);
|
|
7415
7499
|
} catch (err) {
|
|
@@ -7417,13 +7501,29 @@ int main() {
|
|
|
7417
7501
|
}
|
|
7418
7502
|
}
|
|
7419
7503
|
|
|
7504
|
+
if (!isTargetActive) {
|
|
7505
|
+
const targetSess = this._getTerminalSessionById(targetSessionId);
|
|
7506
|
+
if (targetSess && Array.isArray(targetSess.logs) && (!targetXterm || targetXterm.logs !== targetSess.logs)) {
|
|
7507
|
+
const lines = rawText.replace(/\r\n/g, '\n').split('\n');
|
|
7508
|
+
const maxSb = this._getTerminalScrollback();
|
|
7509
|
+
for (const line of lines) {
|
|
7510
|
+
if (line === '') continue;
|
|
7511
|
+
targetSess.logs.push({ type, text: line });
|
|
7512
|
+
}
|
|
7513
|
+
if (targetSess.logs.length > maxSb) {
|
|
7514
|
+
targetSess.logs.splice(0, targetSess.logs.length - maxSb);
|
|
7515
|
+
}
|
|
7516
|
+
}
|
|
7517
|
+
return;
|
|
7518
|
+
}
|
|
7519
|
+
|
|
7420
7520
|
this._activeStreamType = type;
|
|
7421
7521
|
const termLogEl = this.container ? this.container.querySelector('#cl-terminal-log') : null;
|
|
7422
7522
|
const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
|
|
7423
7523
|
const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
|
|
7424
7524
|
|
|
7425
7525
|
// The workbench owns live terminal rendering unless xterm or an attached PTY engine owns the DOM.
|
|
7426
|
-
const ptyOwnsDom = Boolean((
|
|
7526
|
+
const ptyOwnsDom = Boolean((targetXterm && targetXterm.container) || (this.ptyEngine && this.ptyEngine.container));
|
|
7427
7527
|
const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
|
|
7428
7528
|
|
|
7429
7529
|
// Write a single logical line into the live terminal DOM immediately, so output
|
|
@@ -7570,11 +7670,16 @@ int main() {
|
|
|
7570
7670
|
|
|
7571
7671
|
_pushTerminalLog(entry, opts = null) {
|
|
7572
7672
|
if (!entry) return;
|
|
7573
|
-
const
|
|
7574
|
-
|
|
7575
|
-
|
|
7673
|
+
const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || null;
|
|
7674
|
+
const isTargetActive = !targetSessionId || targetSessionId === this._activeTerminalSessionId;
|
|
7675
|
+
const targetSess = isTargetActive ? null : this._getTerminalSessionById(targetSessionId);
|
|
7676
|
+
const targetLogs = targetSess && Array.isArray(targetSess.logs) ? targetSess.logs : this.terminalLogs;
|
|
7677
|
+
const targetXterm = this._getXtermEngineForSessionId(targetSessionId);
|
|
7678
|
+
|
|
7679
|
+
if (targetXterm && targetXterm.logs === targetLogs) {
|
|
7680
|
+
if (!(opts && opts.fromStream) && typeof targetXterm.writeln === 'function') {
|
|
7576
7681
|
try {
|
|
7577
|
-
|
|
7682
|
+
targetXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
|
|
7578
7683
|
} catch (_err) {
|
|
7579
7684
|
void _err;
|
|
7580
7685
|
}
|
|
@@ -7582,12 +7687,12 @@ int main() {
|
|
|
7582
7687
|
this._trimTerminalLogs();
|
|
7583
7688
|
return;
|
|
7584
7689
|
}
|
|
7585
|
-
if (Array.isArray(
|
|
7586
|
-
Array.prototype.push.call(
|
|
7690
|
+
if (Array.isArray(targetLogs)) {
|
|
7691
|
+
Array.prototype.push.call(targetLogs, entry);
|
|
7587
7692
|
}
|
|
7588
|
-
if (
|
|
7693
|
+
if (targetXterm && !(opts && opts.fromStream) && typeof targetXterm.writeln === 'function') {
|
|
7589
7694
|
try {
|
|
7590
|
-
|
|
7695
|
+
targetXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
|
|
7591
7696
|
} catch (_err) {
|
|
7592
7697
|
void _err;
|
|
7593
7698
|
}
|
|
@@ -7678,6 +7783,8 @@ int main() {
|
|
|
7678
7783
|
|
|
7679
7784
|
_handleInterrupt(opts = null) {
|
|
7680
7785
|
const fromXterm = Boolean(opts && opts.fromXterm);
|
|
7786
|
+
const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || null;
|
|
7787
|
+
const targetSession = this._getTerminalSessionById(targetSessionId);
|
|
7681
7788
|
let didInterrupt = false;
|
|
7682
7789
|
if (this._cloneInFlight || this._activeCloneAbortController) {
|
|
7683
7790
|
this.cancelClone();
|
|
@@ -7694,38 +7801,51 @@ int main() {
|
|
|
7694
7801
|
this.logger.debug('cancelWorkerExecution failed.', err);
|
|
7695
7802
|
}
|
|
7696
7803
|
}
|
|
7697
|
-
const
|
|
7804
|
+
const sessionAbort = targetSession ? targetSession.abortController : null;
|
|
7805
|
+
const sessionRunning = Boolean(targetSession && targetSession.isRunning);
|
|
7806
|
+
const isActiveTarget = !targetSession || targetSession.id === this._activeTerminalSessionId;
|
|
7807
|
+
const activeAbort = sessionAbort || (isActiveTarget ? this._activeCommandAbortController : null);
|
|
7808
|
+
const isCommandRunning = Boolean(sessionRunning || activeAbort || (isActiveTarget && (this.isRunning || cancelledWorker)));
|
|
7698
7809
|
const cwdShort = (this.cwd || '/workspace').replace(/^\/workspace\/?/, '') || '~';
|
|
7699
7810
|
const promptLabel = this.inRepl ? '> ' : `codelab:${cwdShort}$`;
|
|
7700
7811
|
|
|
7701
7812
|
if (isCommandRunning) {
|
|
7702
7813
|
didInterrupt = true;
|
|
7703
|
-
if (
|
|
7814
|
+
if (activeAbort) {
|
|
7704
7815
|
try {
|
|
7705
|
-
|
|
7816
|
+
activeAbort.abort('SIGINT');
|
|
7706
7817
|
} catch (err) {
|
|
7707
7818
|
this.logger.debug('AbortController.abort failed.', err);
|
|
7708
7819
|
}
|
|
7709
|
-
|
|
7820
|
+
if (targetSession && targetSession.abortController === activeAbort) {
|
|
7821
|
+
targetSession.abortController = null;
|
|
7822
|
+
}
|
|
7823
|
+
if (this._activeCommandAbortController === activeAbort) {
|
|
7824
|
+
this._activeCommandAbortController = null;
|
|
7825
|
+
}
|
|
7826
|
+
}
|
|
7827
|
+
if (targetSession) {
|
|
7828
|
+
targetSession.isRunning = false;
|
|
7829
|
+
}
|
|
7830
|
+
if (isActiveTarget) {
|
|
7831
|
+
this.isRunning = false;
|
|
7832
|
+
this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
|
|
7710
7833
|
}
|
|
7711
|
-
|
|
7712
|
-
this.isRunning = false;
|
|
7713
|
-
this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
|
|
7714
7834
|
this._updateRunStateUI();
|
|
7715
7835
|
|
|
7716
7836
|
this._flushTerminalStream();
|
|
7717
7837
|
if (!fromXterm) {
|
|
7718
|
-
this._pushTerminalLog({ type: 'stdout', text: '^C' });
|
|
7838
|
+
this._pushTerminalLog({ type: 'stdout', text: '^C' }, { sessionId: targetSessionId });
|
|
7719
7839
|
}
|
|
7720
7840
|
} else {
|
|
7721
7841
|
if (this.inRepl) {
|
|
7722
7842
|
this.inRepl = false;
|
|
7723
7843
|
if (!fromXterm) {
|
|
7724
|
-
this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' });
|
|
7844
|
+
this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' }, { sessionId: targetSessionId });
|
|
7725
7845
|
}
|
|
7726
7846
|
} else if (!fromXterm) {
|
|
7727
7847
|
const currentInput = (this._ptyInputBeforeCursor || '') + (this._ptyInputAfterCursor || '');
|
|
7728
|
-
this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` });
|
|
7848
|
+
this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` }, { sessionId: targetSessionId });
|
|
7729
7849
|
}
|
|
7730
7850
|
}
|
|
7731
7851
|
|
|
@@ -8874,13 +8994,13 @@ int main() {
|
|
|
8874
8994
|
if (this._activeTerminalSessionId !== session.id) {
|
|
8875
8995
|
this.switchTerminalSession(session.id);
|
|
8876
8996
|
}
|
|
8877
|
-
return this._handleReplCommand(cmd, { skipEcho: true });
|
|
8997
|
+
return this._handleReplCommand(cmd, { skipEcho: true, sessionId: session.id });
|
|
8878
8998
|
},
|
|
8879
8999
|
onInterrupt: () => {
|
|
8880
9000
|
if (this._activeTerminalSessionId !== session.id) {
|
|
8881
9001
|
this.switchTerminalSession(session.id);
|
|
8882
9002
|
}
|
|
8883
|
-
this._handleInterrupt({ fromXterm: true });
|
|
9003
|
+
this._handleInterrupt({ fromXterm: true, sessionId: session.id });
|
|
8884
9004
|
},
|
|
8885
9005
|
getCompletions: (buf, cur) => {
|
|
8886
9006
|
const slice = String(buf || '').slice(0, typeof cur === 'number' ? cur : String(buf || '').length);
|
|
@@ -9759,7 +9879,7 @@ int main() {
|
|
|
9759
9879
|
this._renderDrawerBody();
|
|
9760
9880
|
|
|
9761
9881
|
try {
|
|
9762
|
-
const res = await this.shell.execute(`serve ${rootDir}`, {});
|
|
9882
|
+
const res = await this.shell.execute(`serve ${rootDir}`, { isBackground: true });
|
|
9763
9883
|
if (res && res.stdout) this._pushTerminalLog({ type: 'stdout', text: res.stdout.replace(/\n$/, '') });
|
|
9764
9884
|
if (res && res.stderr) this._pushTerminalLog({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
|
|
9765
9885
|
} catch (err) {
|
|
@@ -13806,6 +13926,7 @@ int main() {
|
|
|
13806
13926
|
{ id: 'toggle-guide', label: 'View: Toggle Guide Sidebar', action: () => this.toggleGuide() },
|
|
13807
13927
|
{ id: 'toggle-drawer', label: 'View: Toggle Panel Visibility', shortcut: '⌘J', action: () => this.togglePanel() },
|
|
13808
13928
|
{ id: 'toggle-terminal', label: 'View: Toggle Terminal', shortcut: '⌃`', action: () => this.toggleTerminal() },
|
|
13929
|
+
{ id: 'toggle-zen-mode', label: 'View: Toggle Zen Mode', action: () => this.toggleZenMode() },
|
|
13809
13930
|
{ id: 'toggle-fullscreen', label: 'View: Toggle Fullscreen Workbench', action: () => this.toggleFullscreen() },
|
|
13810
13931
|
{ id: 'search-workspace', label: 'Search: Find & Replace Across Files...', shortcut: '⇧⌘F', action: () => this.openSearchView() },
|
|
13811
13932
|
{ id: 'open-scm', label: 'Git: Source Control (Status, Stage & Commit)...', shortcut: '⌃⇧G', action: () => this.openScmView() },
|
|
@@ -14903,6 +15024,91 @@ int main() {
|
|
|
14903
15024
|
if (this.editor) setTimeout(() => this.editor.layout(), 50);
|
|
14904
15025
|
}
|
|
14905
15026
|
|
|
15027
|
+
/**
|
|
15028
|
+
* Imports local OS files dropped into the Explorer into the workspace and VFS.
|
|
15029
|
+
*/
|
|
15030
|
+
async importDroppedFiles(fileList, targetFolder = '') {
|
|
15031
|
+
const items = fileList ? Array.from(fileList) : [];
|
|
15032
|
+
if (items.length === 0) return [];
|
|
15033
|
+
const prefix = String(targetFolder || '').replace(/^\/+|\/+$/g, '');
|
|
15034
|
+
const reservedRe = /(?:^|\/)(?:\.git|node_modules)(?:\/|$)/;
|
|
15035
|
+
const MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
15036
|
+
const imported = [];
|
|
15037
|
+
let skipped = 0;
|
|
15038
|
+
|
|
15039
|
+
for (const file of items) {
|
|
15040
|
+
if (!file || typeof file.name !== 'string') continue;
|
|
15041
|
+
if (typeof file.size === 'number' && file.size > MAX_FILE_BYTES) {
|
|
15042
|
+
skipped++;
|
|
15043
|
+
continue;
|
|
15044
|
+
}
|
|
15045
|
+
const rawRel = (file.webkitRelativePath && String(file.webkitRelativePath).trim()) || file.name;
|
|
15046
|
+
const cleanRel = rawRel.replace(/\\/g, '/').replace(/^\/+/, '');
|
|
15047
|
+
const fullRel = prefix ? `${prefix}/${cleanRel}` : cleanRel;
|
|
15048
|
+
const normalized = this._normalizeWorkspaceRelPath(fullRel);
|
|
15049
|
+
if (!normalized || reservedRe.test(normalized)) {
|
|
15050
|
+
skipped++;
|
|
15051
|
+
continue;
|
|
15052
|
+
}
|
|
15053
|
+
try {
|
|
15054
|
+
const text = typeof file.text === 'function' ? await file.text() : String(file.content ?? '');
|
|
15055
|
+
this.files[normalized] = text;
|
|
15056
|
+
this._vfsWriteFile(normalized, text);
|
|
15057
|
+
imported.push(normalized);
|
|
15058
|
+
} catch (err) {
|
|
15059
|
+
this.logger.debug('Skipped unreadable dropped file.', normalized, err);
|
|
15060
|
+
skipped++;
|
|
15061
|
+
}
|
|
15062
|
+
}
|
|
15063
|
+
|
|
15064
|
+
if (imported.length > 0) {
|
|
15065
|
+
this._isBlankBase = false;
|
|
15066
|
+
this._syncAllModels();
|
|
15067
|
+
this._renderFileLists();
|
|
15068
|
+
this.openFile(imported[0]);
|
|
15069
|
+
this._saveState({ flushFiles: true });
|
|
15070
|
+
this._lintAllWorkspaceFiles();
|
|
15071
|
+
this._updateStatusBar();
|
|
15072
|
+
if (typeof this._showToast === 'function') {
|
|
15073
|
+
const extra = skipped > 0 ? ` (${skipped} skipped)` : '';
|
|
15074
|
+
this._showToast(`Imported ${imported.length} file${imported.length === 1 ? '' : 's'}${extra}`, 'success');
|
|
15075
|
+
}
|
|
15076
|
+
} else if (skipped > 0 && typeof this._showToast === 'function') {
|
|
15077
|
+
this._showToast(`Skipped ${skipped} unsupported or oversized file${skipped === 1 ? '' : 's'} (> 2 MB).`, 'warning');
|
|
15078
|
+
}
|
|
15079
|
+
return imported;
|
|
15080
|
+
}
|
|
15081
|
+
|
|
15082
|
+
/**
|
|
15083
|
+
* Toggles distraction-free Zen Mode by hiding sidebar, bottom panel, and status bar.
|
|
15084
|
+
*/
|
|
15085
|
+
toggleZenMode() {
|
|
15086
|
+
const shell = this.container ? this.container.querySelector('.codelab') : null;
|
|
15087
|
+
if (!shell) return false;
|
|
15088
|
+
this.isZenMode = !this.isZenMode;
|
|
15089
|
+
if (this.isZenMode) {
|
|
15090
|
+
this._zenPriorState = {
|
|
15091
|
+
sidebarVisible: this.sidebarVisible !== false,
|
|
15092
|
+
panelVisible: this.panelVisible !== false
|
|
15093
|
+
};
|
|
15094
|
+
shell.classList.add('is-zen-mode');
|
|
15095
|
+
this.setSidebarVisible(false);
|
|
15096
|
+
this.setPanelVisible(false);
|
|
15097
|
+
if (typeof this._showToast === 'function') {
|
|
15098
|
+
this._showToast('Zen Mode enabled — run "View: Toggle Zen Mode" to exit', 'info');
|
|
15099
|
+
}
|
|
15100
|
+
} else {
|
|
15101
|
+
shell.classList.remove('is-zen-mode');
|
|
15102
|
+
const prior = this._zenPriorState || { sidebarVisible: true, panelVisible: true };
|
|
15103
|
+
this.setSidebarVisible(Boolean(prior.sidebarVisible));
|
|
15104
|
+
this.setPanelVisible(Boolean(prior.panelVisible));
|
|
15105
|
+
}
|
|
15106
|
+
if (this.editor && typeof this.editor.layout === 'function') {
|
|
15107
|
+
setTimeout(() => this.editor.layout(), 50);
|
|
15108
|
+
}
|
|
15109
|
+
return this.isZenMode;
|
|
15110
|
+
}
|
|
15111
|
+
|
|
14906
15112
|
stopExecution() {
|
|
14907
15113
|
this._handleInterrupt();
|
|
14908
15114
|
}
|
|
@@ -17629,31 +17835,56 @@ int main() {
|
|
|
17629
17835
|
);
|
|
17630
17836
|
|
|
17631
17837
|
if (this.shell && typeof this.shell.execute === 'function' && !looksLikeJsExpr) {
|
|
17838
|
+
const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || 'session-1';
|
|
17839
|
+
const targetSession = this._getTerminalSessionById(targetSessionId);
|
|
17632
17840
|
const abortCtrl = new AbortController();
|
|
17633
|
-
|
|
17634
|
-
|
|
17841
|
+
if (targetSession) {
|
|
17842
|
+
targetSession.abortController = abortCtrl;
|
|
17843
|
+
targetSession.isRunning = true;
|
|
17844
|
+
}
|
|
17845
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17846
|
+
this._activeCommandAbortController = abortCtrl;
|
|
17847
|
+
this.isRunning = true;
|
|
17848
|
+
}
|
|
17635
17849
|
this._updateRunStateUI();
|
|
17636
17850
|
let streamedStdout = false;
|
|
17637
17851
|
let streamedStderr = false;
|
|
17638
17852
|
|
|
17639
17853
|
try {
|
|
17640
17854
|
this._syncFilesToShellVfs();
|
|
17641
|
-
this.shell.cwd = this.cwd || '/workspace';
|
|
17855
|
+
this.shell.cwd = (targetSession && targetSession.cwd) || this.cwd || '/workspace';
|
|
17856
|
+
if (targetSession) {
|
|
17857
|
+
if (!targetSession.env || typeof targetSession.env !== 'object') {
|
|
17858
|
+
targetSession.env = { ...this._getBaseShellEnv(), PWD: this.shell.cwd };
|
|
17859
|
+
}
|
|
17860
|
+
this.shell.env = { ...targetSession.env, PWD: this.shell.cwd };
|
|
17861
|
+
}
|
|
17642
17862
|
const shellRes = await this.shell.execute(trimmed, {
|
|
17643
17863
|
onStdout: (c) => {
|
|
17644
17864
|
streamedStdout = true;
|
|
17645
|
-
this._appendTerminalStream('stdout', c);
|
|
17865
|
+
this._appendTerminalStream('stdout', c, targetSessionId);
|
|
17646
17866
|
},
|
|
17647
17867
|
onStderr: (c) => {
|
|
17648
17868
|
streamedStderr = true;
|
|
17649
|
-
this._appendTerminalStream('stderr', c);
|
|
17869
|
+
this._appendTerminalStream('stderr', c, targetSessionId);
|
|
17650
17870
|
},
|
|
17651
17871
|
onRequestStdin: (promptText) => this._requestInteractiveTerminalStdin(promptText, abortCtrl.signal),
|
|
17652
17872
|
signal: abortCtrl.signal
|
|
17653
17873
|
});
|
|
17654
|
-
this.
|
|
17874
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17875
|
+
this._flushTerminalStream();
|
|
17876
|
+
}
|
|
17655
17877
|
const aborted = this._isAbortResult(shellRes, abortCtrl.signal);
|
|
17656
|
-
|
|
17878
|
+
const nextCwd = this.shell.cwd || (targetSession && targetSession.cwd) || this.cwd;
|
|
17879
|
+
if (targetSession) {
|
|
17880
|
+
targetSession.cwd = nextCwd;
|
|
17881
|
+
if (this.shell && this.shell.env && typeof this.shell.env === 'object') {
|
|
17882
|
+
targetSession.env = { ...this.shell.env, PWD: nextCwd };
|
|
17883
|
+
}
|
|
17884
|
+
}
|
|
17885
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17886
|
+
this.cwd = nextCwd;
|
|
17887
|
+
}
|
|
17657
17888
|
this._syncVfsSnapshot(null, true);
|
|
17658
17889
|
if (/^\s*git\b/.test(trimmed) || (this.shell && this.shell.gitState && this.shell.gitState.initialized)) {
|
|
17659
17890
|
this._saveState();
|
|
@@ -17666,39 +17897,56 @@ int main() {
|
|
|
17666
17897
|
this._updateStatusBar();
|
|
17667
17898
|
|
|
17668
17899
|
if (shellRes && shellRes.clear) {
|
|
17669
|
-
this.
|
|
17900
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17901
|
+
this._clearTerminalLogs();
|
|
17902
|
+
} else if (targetSession) {
|
|
17903
|
+
targetSession.logs = [];
|
|
17904
|
+
}
|
|
17670
17905
|
this._renderDrawerBody();
|
|
17671
17906
|
return;
|
|
17672
17907
|
}
|
|
17673
17908
|
if (shellRes && shellRes.interactiveRepl) {
|
|
17674
|
-
|
|
17909
|
+
if (targetSession) targetSession.inRepl = true;
|
|
17910
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17911
|
+
this.inRepl = true;
|
|
17912
|
+
}
|
|
17675
17913
|
if (shellRes.stdout && !streamedStdout) {
|
|
17676
|
-
this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
|
|
17914
|
+
this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') }, { sessionId: targetSessionId });
|
|
17677
17915
|
}
|
|
17678
17916
|
this._renderDrawerBody();
|
|
17679
17917
|
return;
|
|
17680
17918
|
}
|
|
17681
17919
|
|
|
17682
17920
|
if (!aborted && shellRes && shellRes.stdout && !streamedStdout) {
|
|
17683
|
-
this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
|
|
17921
|
+
this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') }, { sessionId: targetSessionId });
|
|
17684
17922
|
}
|
|
17685
17923
|
if (!aborted && shellRes && shellRes.stderr && !streamedStderr) {
|
|
17686
|
-
this._pushTerminalLog({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') });
|
|
17924
|
+
this._pushTerminalLog({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') }, { sessionId: targetSessionId });
|
|
17687
17925
|
}
|
|
17688
17926
|
this._renderDrawerBody();
|
|
17689
17927
|
return;
|
|
17690
17928
|
} catch (err) {
|
|
17691
|
-
this.
|
|
17929
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17930
|
+
this._flushTerminalStream();
|
|
17931
|
+
}
|
|
17692
17932
|
if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
|
|
17693
|
-
this._pushTerminalLog({ type: 'stderr', text: formatErrorText(err) });
|
|
17933
|
+
this._pushTerminalLog({ type: 'stderr', text: formatErrorText(err) }, { sessionId: targetSessionId });
|
|
17694
17934
|
}
|
|
17695
17935
|
this._renderDrawerBody();
|
|
17696
17936
|
return;
|
|
17697
17937
|
} finally {
|
|
17938
|
+
if (targetSession) {
|
|
17939
|
+
if (targetSession.abortController === abortCtrl) {
|
|
17940
|
+
targetSession.abortController = null;
|
|
17941
|
+
}
|
|
17942
|
+
targetSession.isRunning = false;
|
|
17943
|
+
}
|
|
17698
17944
|
if (this._activeCommandAbortController === abortCtrl) {
|
|
17699
17945
|
this._activeCommandAbortController = null;
|
|
17700
17946
|
}
|
|
17701
|
-
this.
|
|
17947
|
+
if (targetSessionId === this._activeTerminalSessionId) {
|
|
17948
|
+
this.isRunning = false;
|
|
17949
|
+
}
|
|
17702
17950
|
this._updateRunStateUI();
|
|
17703
17951
|
}
|
|
17704
17952
|
}
|
|
@@ -19335,6 +19583,7 @@ int main() {
|
|
|
19335
19583
|
label: 'Appearance',
|
|
19336
19584
|
submenu: [
|
|
19337
19585
|
{ label: 'Full Screen', cmd: 'view:fullscreen' },
|
|
19586
|
+
{ label: 'Zen Mode', cmd: 'view:zen-mode' },
|
|
19338
19587
|
{ label: 'Move Primary Side Bar Left / Right', cmd: 'view:toggle-sidebar-side' },
|
|
19339
19588
|
{ label: 'Toggle Status Bar', cmd: 'view:toggle-statusbar' },
|
|
19340
19589
|
{ divider: true },
|
|
@@ -19611,6 +19860,8 @@ int main() {
|
|
|
19611
19860
|
this.togglePanel();
|
|
19612
19861
|
} else if (cmd === 'view:fullscreen') {
|
|
19613
19862
|
this.toggleFullscreen();
|
|
19863
|
+
} else if (cmd === 'view:zen-mode') {
|
|
19864
|
+
this.toggleZenMode();
|
|
19614
19865
|
} else if (cmd === 'view:toggle-sidebar-side') {
|
|
19615
19866
|
if (this.configuration && typeof this.configuration.setUserSetting === 'function') {
|
|
19616
19867
|
const cur = this.configuration.get('workbench.sidebar.defaultLocation', 'left');
|
|
@@ -20306,17 +20557,33 @@ int main() {
|
|
|
20306
20557
|
}).join('');
|
|
20307
20558
|
}
|
|
20308
20559
|
|
|
20560
|
+
_getBaseShellEnv() {
|
|
20561
|
+
if (!this._baseShellEnv && this.shell && this.shell.env && typeof this.shell.env === 'object') {
|
|
20562
|
+
this._baseShellEnv = { ...this.shell.env };
|
|
20563
|
+
}
|
|
20564
|
+
return this._baseShellEnv
|
|
20565
|
+
? { ...this._baseShellEnv }
|
|
20566
|
+
: { HOME: '/workspace', PWD: '/workspace', PATH: '/usr/local/bin:/usr/bin:/bin' };
|
|
20567
|
+
}
|
|
20568
|
+
|
|
20309
20569
|
_saveActiveTerminalSessionState() {
|
|
20310
20570
|
if (!Array.isArray(this._terminalSessions)) return;
|
|
20311
20571
|
const active = this._terminalSessions.find((s) => s.id === this._activeTerminalSessionId);
|
|
20312
20572
|
if (!active) return;
|
|
20313
20573
|
active.cwd = this.cwd || (this.shell && this.shell.cwd) || '/workspace';
|
|
20574
|
+
if (this.shell && this.shell.env && typeof this.shell.env === 'object') {
|
|
20575
|
+
active.env = { ...this.shell.env, PWD: active.cwd };
|
|
20576
|
+
}
|
|
20314
20577
|
active.inRepl = Boolean(this.inRepl);
|
|
20315
20578
|
active.replLang = this.replLang || 'node';
|
|
20316
20579
|
active.replHistory = Array.isArray(this.replHistory) ? this.replHistory.slice() : [];
|
|
20317
20580
|
active.replHistoryIdx = typeof this.replHistoryIdx === 'number' ? this.replHistoryIdx : -1;
|
|
20318
20581
|
active.beforeCursor = this._ptyInputBeforeCursor || '';
|
|
20319
20582
|
active.afterCursor = this._ptyInputAfterCursor || '';
|
|
20583
|
+
active.isRunning = Boolean(active.isRunning || this.isRunning);
|
|
20584
|
+
if (this._activeCommandAbortController && !active.abortController) {
|
|
20585
|
+
active.abortController = this._activeCommandAbortController;
|
|
20586
|
+
}
|
|
20320
20587
|
if (Array.isArray(this.terminalLogs)) {
|
|
20321
20588
|
active.logs = this.terminalLogs;
|
|
20322
20589
|
}
|
|
@@ -20330,9 +20597,10 @@ int main() {
|
|
|
20330
20597
|
this.cwd = target.cwd || '/workspace';
|
|
20331
20598
|
if (this.shell) {
|
|
20332
20599
|
this.shell.cwd = this.cwd;
|
|
20333
|
-
if (
|
|
20334
|
-
|
|
20600
|
+
if (!target.env || typeof target.env !== 'object') {
|
|
20601
|
+
target.env = { ...this._getBaseShellEnv(), PWD: this.cwd };
|
|
20335
20602
|
}
|
|
20603
|
+
this.shell.env = { ...target.env, PWD: this.cwd };
|
|
20336
20604
|
}
|
|
20337
20605
|
this.inRepl = Boolean(target.inRepl);
|
|
20338
20606
|
this.replLang = target.replLang || 'node';
|
|
@@ -20340,15 +20608,22 @@ int main() {
|
|
|
20340
20608
|
this.replHistoryIdx = typeof target.replHistoryIdx === 'number' ? target.replHistoryIdx : -1;
|
|
20341
20609
|
this._ptyInputBeforeCursor = target.beforeCursor || '';
|
|
20342
20610
|
this._ptyInputAfterCursor = target.afterCursor || '';
|
|
20611
|
+
this.isRunning = Boolean(target.isRunning);
|
|
20612
|
+
this._activeCommandAbortController = target.abortController || null;
|
|
20613
|
+
if (typeof this._updateRunStateUI === 'function') {
|
|
20614
|
+
this._updateRunStateUI();
|
|
20615
|
+
}
|
|
20343
20616
|
}
|
|
20344
20617
|
|
|
20345
20618
|
_ensureTerminalSessions() {
|
|
20346
20619
|
if (!Array.isArray(this._terminalSessions) || this._terminalSessions.length === 0) {
|
|
20620
|
+
const initCwd = this.cwd || (this.shell && this.shell.cwd) || '/workspace';
|
|
20347
20621
|
this._terminalSessions = [
|
|
20348
20622
|
{
|
|
20349
20623
|
id: 'session-1',
|
|
20350
20624
|
name: 'bash-1',
|
|
20351
|
-
cwd:
|
|
20625
|
+
cwd: initCwd,
|
|
20626
|
+
env: { ...this._getBaseShellEnv(), PWD: initCwd },
|
|
20352
20627
|
logs: Array.isArray(this.terminalLogs) ? this.terminalLogs : (this.terminalLogs = []),
|
|
20353
20628
|
inRepl: Boolean(this.inRepl),
|
|
20354
20629
|
replLang: this.replLang || 'node',
|
|
@@ -20386,6 +20661,7 @@ int main() {
|
|
|
20386
20661
|
id,
|
|
20387
20662
|
name: label,
|
|
20388
20663
|
cwd: '/workspace',
|
|
20664
|
+
env: { ...this._getBaseShellEnv(), PWD: '/workspace' },
|
|
20389
20665
|
logs: [],
|
|
20390
20666
|
inRepl: false,
|
|
20391
20667
|
replLang: 'node',
|
|
@@ -20458,6 +20734,11 @@ int main() {
|
|
|
20458
20734
|
|
|
20459
20735
|
this._saveActiveTerminalSessionState();
|
|
20460
20736
|
const removed = sessions.splice(idx, 1)[0];
|
|
20737
|
+
if (removed && removed.abortController) {
|
|
20738
|
+
try { removed.abortController.abort('SIGINT'); } catch (_err) { void _err; }
|
|
20739
|
+
removed.abortController = null;
|
|
20740
|
+
removed.isRunning = false;
|
|
20741
|
+
}
|
|
20461
20742
|
if (this._xtermEngines instanceof Map && removed) {
|
|
20462
20743
|
const oldEng = this._xtermEngines.get(removed.id);
|
|
20463
20744
|
if (oldEng && typeof oldEng.destroy === 'function') {
|
|
@@ -21711,6 +21992,8 @@ int main() {
|
|
|
21711
21992
|
openSettings(opts) { if (this._instance) this._instance.openSettings(opts); }
|
|
21712
21993
|
closeSettings() { if (this._instance) this._instance.closeSettings(); }
|
|
21713
21994
|
openWorkspaceSettingsJson() { if (this._instance) this._instance.openWorkspaceSettingsJson(); }
|
|
21995
|
+
toggleZenMode() { return this._instance ? this._instance.toggleZenMode() : false; }
|
|
21996
|
+
importDroppedFiles(fileList, targetFolder = '') { return this._instance ? this._instance.importDroppedFiles(fileList, targetFolder) : Promise.resolve([]); }
|
|
21714
21997
|
runSql(mode, payload) { return this._instance ? this._instance.runSql(mode, payload) : Promise.resolve(null); }
|
|
21715
21998
|
setSqlSchema(schema) { if (this._instance) this._instance.setSqlSchema(schema); return this; }
|
|
21716
21999
|
setSqlDialect(dialect) { if (this._instance) this._instance.setSqlDialect(dialect); return this; }
|