@innovatorved/code-lab 0.6.0 → 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.
Files changed (62) hide show
  1. package/ARCHITECTURE.md +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/README.md +38 -1
  4. package/dist/code-lab-sql.css +87 -64
  5. package/dist/code-lab-sql.esm.js +109 -86
  6. package/dist/code-lab-sql.umd.js +110 -87
  7. package/dist/code-lab.css +1 -1
  8. package/dist/code-lab.d.ts +19 -1
  9. package/dist/code-lab.esm.js +1261 -900
  10. package/dist/code-lab.js +1260 -899
  11. package/dist/code-lab.umd.js +1260 -899
  12. package/dist/extensions/cpp.esm.js +9 -0
  13. package/dist/extensions/cpp.js +9 -0
  14. package/dist/extensions/guided-lab.esm.js +9 -0
  15. package/dist/extensions/guided-lab.js +9 -0
  16. package/dist/extensions/python.esm.js +9 -0
  17. package/dist/extensions/python.js +9 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/packages/sql/src/styles.d.ts +1 -1
  20. package/dist/packages/ui/src/settings-dialog.d.ts +2 -0
  21. package/dist/preview-sw.js +1 -1
  22. package/dist/runtime.esm.js +70 -70
  23. package/dist/runtime.js +70 -70
  24. package/dist/schemas.d.ts +13 -1
  25. package/dist/schemas.esm.js +9 -0
  26. package/dist/schemas.js +9 -0
  27. package/dist/shell.esm.js +250 -244
  28. package/dist/shell.js +250 -244
  29. package/dist/terminal.esm.js +1 -1
  30. package/dist/terminal.js +1 -1
  31. package/dist/workbench/index.d.ts +1 -1
  32. package/dist/workbench/intellisense.d.ts +1 -1
  33. package/dist/workbench/styles.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/packages/commands/package.json +1 -1
  36. package/packages/core/package.json +1 -1
  37. package/packages/editor/package.json +1 -1
  38. package/packages/fs/package.json +1 -1
  39. package/packages/preview/package.json +1 -1
  40. package/packages/runtime/package.json +1 -1
  41. package/packages/settings/package.json +1 -1
  42. package/packages/settings/src/builtin-schemas.ts +16 -0
  43. package/packages/sql/package.json +1 -1
  44. package/packages/sql/src/styles.ts +87 -64
  45. package/packages/terminal/package.json +1 -1
  46. package/packages/ui/package.json +1 -1
  47. package/packages/ui/src/observability.ts +12 -14
  48. package/packages/ui/src/settings-dialog.ts +409 -57
  49. package/packages/ui/src/themes.ts +78 -78
  50. package/src/code-lab.css +757 -310
  51. package/src/index.ts +1 -1
  52. package/src/runtime.ts +29 -3
  53. package/src/schemas.ts +10 -1
  54. package/src/shell.ts +106 -16
  55. package/src/workbench/diff-editor.ts +5 -1
  56. package/src/workbench/drawer.ts +5 -5
  57. package/src/workbench/icons.ts +5 -5
  58. package/src/workbench/intellisense.ts +94 -82
  59. package/src/workbench/styles.ts +58 -54
  60. package/src/workbench/toolbar.ts +1 -1
  61. package/src/workbench/xterm-adapter.ts +61 -56
  62. package/src/workbench.ts +462 -173
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.6.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 = `
@@ -1019,36 +1019,37 @@ declare module 'bun:sqlite' {
1019
1019
  reject(new Error('Monaco failed to initialize'));
1020
1020
  return;
1021
1021
  }
1022
- // Define custom themes synced with Ved Gupta Monochrome Neutral Design System (Geist)
1022
+ // Define custom themes synced with Ved Gupta Monochrome Charcoal Ink & Warm Paper Design System (Geist)
1023
1023
  m.editor.defineTheme('codelab-dark', {
1024
1024
  base: 'vs-dark',
1025
1025
  inherit: true,
1026
1026
  rules: [
1027
- { token: 'comment', foreground: '666666', fontStyle: 'italic' },
1028
- { token: 'keyword', foreground: 'ff7b72' },
1029
- { token: 'string', foreground: 'a5d6ff' },
1030
- { token: 'number', foreground: '79c0ff' },
1031
- { token: 'type', foreground: 'ffa657' }
1027
+ { token: 'comment', foreground: '8e8e97', fontStyle: 'italic' },
1028
+ { token: 'keyword', foreground: 'f87171' },
1029
+ { token: 'string', foreground: '86efac' },
1030
+ { token: 'number', foreground: 'fcd34d' },
1031
+ { token: 'type', foreground: 'fb923c' },
1032
+ { token: 'function', foreground: 'c084fc' }
1032
1033
  ],
1033
1034
  colors: {
1034
- 'editor.background': '#000000',
1035
- 'editor.foreground': '#f2f2f2',
1036
- 'editorGutter.background': '#000000',
1037
- 'editorLineNumber.foreground': '#525252',
1038
- 'editorLineNumber.activeForeground': '#ffffff',
1039
- 'editor.lineHighlightBackground': '#0a0a0a',
1040
- 'editor.lineHighlightBorder': '#171717',
1041
- 'editor.selectionBackground': '#262626',
1042
- 'editor.inactiveSelectionBackground': '#171717',
1043
- 'editorCursor.foreground': '#ffffff',
1044
- 'editorIndentGuide.background1': '#171717',
1045
- 'editorIndentGuide.activeBackground1': '#262626',
1046
- 'editorWidget.background': '#0a0a0a',
1047
- 'editorWidget.border': '#262626',
1048
- 'editorHoverWidget.background': '#0a0a0a',
1049
- 'editorHoverWidget.border': '#262626',
1050
- 'scrollbarSlider.background': '#26262680',
1051
- 'scrollbarSlider.hoverBackground': '#404040aa'
1035
+ 'editor.background': '#0f0f10',
1036
+ 'editor.foreground': '#f4f4f5',
1037
+ 'editorGutter.background': '#0f0f10',
1038
+ 'editorLineNumber.foreground': '#6e6e77',
1039
+ 'editorLineNumber.activeForeground': '#f4f4f5',
1040
+ 'editor.lineHighlightBackground': '#18181a99',
1041
+ 'editor.lineHighlightBorder': '#00000000',
1042
+ 'editor.selectionBackground': '#28282b',
1043
+ 'editor.inactiveSelectionBackground': '#1f1f22',
1044
+ 'editorCursor.foreground': '#f4f4f5',
1045
+ 'editorIndentGuide.background1': '#27272a80',
1046
+ 'editorIndentGuide.activeBackground1': '#3a3a3e',
1047
+ 'editorWidget.background': '#18181a',
1048
+ 'editorWidget.border': '#27272a',
1049
+ 'editorHoverWidget.background': '#18181a',
1050
+ 'editorHoverWidget.border': '#27272a',
1051
+ 'scrollbarSlider.background': '#3a3a3e66',
1052
+ 'scrollbarSlider.hoverBackground': '#52525b99'
1052
1053
  }
1053
1054
  });
1054
1055
 
@@ -1056,25 +1057,30 @@ declare module 'bun:sqlite' {
1056
1057
  base: 'vs',
1057
1058
  inherit: true,
1058
1059
  rules: [
1059
- { token: 'comment', foreground: '666666', fontStyle: 'italic' }
1060
+ { token: 'comment', foreground: '6e6a64', fontStyle: 'italic' },
1061
+ { token: 'keyword', foreground: 'c2410c' },
1062
+ { token: 'string', foreground: '067647' },
1063
+ { token: 'number', foreground: 'b54708' },
1064
+ { token: 'type', foreground: '9a3412' },
1065
+ { token: 'function', foreground: '6d28d9' }
1060
1066
  ],
1061
1067
  colors: {
1062
1068
  'editor.background': '#ffffff',
1063
- 'editor.foreground': '#0a0a0a',
1069
+ 'editor.foreground': '#18181b',
1064
1070
  'editorGutter.background': '#ffffff',
1065
- 'editorLineNumber.foreground': '#8f8f8f',
1066
- 'editorLineNumber.activeForeground': '#0a0a0a',
1067
- 'editor.lineHighlightBackground': '#fafafa',
1068
- 'editor.lineHighlightBorder': '#f5f5f5',
1069
- 'editor.selectionBackground': '#e5e5e5',
1070
- 'editor.inactiveSelectionBackground': '#f5f5f5',
1071
- 'editorCursor.foreground': '#000000',
1072
- 'editorIndentGuide.background1': '#f0f0f0',
1073
- 'editorIndentGuide.activeBackground1': '#d4d4d4',
1074
- 'editorWidget.background': '#fafafa',
1075
- 'editorWidget.border': '#e5e5e5',
1076
- 'editorHoverWidget.background': '#fafafa',
1077
- 'editorHoverWidget.border': '#e5e5e5'
1071
+ 'editorLineNumber.foreground': '#8a8680',
1072
+ 'editorLineNumber.activeForeground': '#18181b',
1073
+ 'editor.lineHighlightBackground': '#f7f7f5',
1074
+ 'editor.lineHighlightBorder': '#00000000',
1075
+ 'editor.selectionBackground': '#e6e4df',
1076
+ 'editor.inactiveSelectionBackground': '#f1f1ee',
1077
+ 'editorCursor.foreground': '#18181b',
1078
+ 'editorIndentGuide.background1': '#e6e4df',
1079
+ 'editorIndentGuide.activeBackground1': '#d3d0c9',
1080
+ 'editorWidget.background': '#f7f7f5',
1081
+ 'editorWidget.border': '#e6e4df',
1082
+ 'editorHoverWidget.background': '#f7f7f5',
1083
+ 'editorHoverWidget.border': '#e6e4df'
1078
1084
  }
1079
1085
  });
1080
1086
 
@@ -2101,10 +2107,20 @@ int main() {
2101
2107
  }
2102
2108
 
2103
2109
  // Load persisted user settings from localStorage if available
2110
+ const persistedUserKeys = new Set();
2104
2111
  if (this.persistState && this.configuration) {
2105
2112
  const savedUserSettings = safeStorageGet(`${STORAGE_PREFIX}user-settings`, this.logger);
2106
2113
  if (savedUserSettings) {
2107
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
+ }
2108
2124
  }
2109
2125
  }
2110
2126
 
@@ -2121,9 +2137,35 @@ int main() {
2121
2137
  }
2122
2138
  }
2123
2139
 
2124
- // Apply constructor overrides onto Layer 4 if passed in options.settings
2125
- if (this.options && this.options.settings && typeof this.options.settings === 'object' && this.configuration) {
2126
- this.configuration.setOverrides(this.options.settings);
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
+ }
2127
2169
  }
2128
2170
 
2129
2171
  // Register built-in commands & keybindings
@@ -3517,38 +3559,35 @@ int main() {
3517
3559
  }
3518
3560
  }
3519
3561
  }
3520
- if (targetFile && this.files[targetFile] !== undefined) {
3521
- this._syncDotCodelabConfig();
3522
- this._vfsWriteFile(targetFile, this.files[targetFile]);
3523
- } else {
3524
- this._syncFilesToShellVfs();
3525
- }
3526
- if (!this._savedSnapshot) this._savedSnapshot = {};
3527
- const autoSaveMode = this.configuration
3528
- ? this.configuration.get('files.autoSave', 'afterDelay')
3529
- : 'afterDelay';
3530
- if (saveAll || !targetFile || (autoSaveMode !== 'off' && autoSaveMode !== 'onFocusChange')) {
3531
- this._savedSnapshot = { ...(this.files || {}) };
3532
- this._clearFileDirty();
3533
- this._saveState({ flushFiles: true });
3534
- } else {
3535
- if (this.files[targetFile] !== undefined) {
3536
- 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]);
3537
3566
  } else {
3538
- delete this._savedSnapshot[targetFile];
3567
+ this._syncFilesToShellVfs();
3539
3568
  }
3540
- this._clearFileDirty(targetFile);
3541
- this._saveState({ flushSnapshotOnly: true });
3542
- }
3543
- if (formatPromise && typeof formatPromise.then === 'function') {
3544
- formatPromise.then(() => {
3545
- if (this._destroyed) return;
3546
- if (targetFile && this.files[targetFile] !== undefined) {
3547
- this._vfsWriteFile(targetFile, this.files[targetFile]);
3548
- if (this._savedSnapshot) this._savedSnapshot[targetFile] = this.files[targetFile];
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];
3549
3582
  }
3550
- this._clearFileDirty(saveAll ? undefined : targetFile);
3583
+ this._clearFileDirty(targetFile);
3551
3584
  this._saveState({ flushSnapshotOnly: true });
3585
+ }
3586
+ };
3587
+ finalizeSave();
3588
+ if (formatPromise && typeof formatPromise.then === 'function') {
3589
+ formatPromise.then(() => {
3590
+ if (!this._destroyed) finalizeSave();
3552
3591
  }).catch((err) => {
3553
3592
  this.logger.debug('Async formatOnSave completion skipped.', err);
3554
3593
  });
@@ -4291,6 +4330,17 @@ int main() {
4291
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 => {
4292
4331
  btn.disabled = this.isRunning;
4293
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
+ }
4294
4344
  this._updatePtyActiveLine();
4295
4345
  }
4296
4346
 
@@ -5288,7 +5338,7 @@ int main() {
5288
5338
  </div>
5289
5339
  ` : `
5290
5340
  <div class="codelab-guide__footer-row">
5291
- <span style="font-size:11.5px;color:var(--cl-fg-muted);">100% In-Browser Web Worker Sandbox</span>
5341
+ <span class="cl-ui-muted-note">100% In-Browser Web Worker Sandbox</span>
5292
5342
  </div>
5293
5343
  `}
5294
5344
  `;
@@ -5735,11 +5785,16 @@ int main() {
5735
5785
  });
5736
5786
  });
5737
5787
 
5788
+ const isExternalFilesDrag = (ev) =>
5789
+ Boolean(ev.dataTransfer && ev.dataTransfer.types && Array.from(ev.dataTransfer.types).includes('Files'));
5790
+
5738
5791
  // Attach folder drop events
5739
5792
  explorerEl.querySelectorAll('.codelab-folder-item').forEach(el => {
5740
5793
  el.addEventListener('dragover', ev => {
5741
5794
  ev.preventDefault();
5742
- if (ev.dataTransfer) ev.dataTransfer.dropEffect = 'move';
5795
+ if (ev.dataTransfer) {
5796
+ ev.dataTransfer.dropEffect = isExternalFilesDrag(ev) ? 'copy' : 'move';
5797
+ }
5743
5798
  el.classList.add('drag-over');
5744
5799
  });
5745
5800
  el.addEventListener('dragleave', () => {
@@ -5749,23 +5804,42 @@ int main() {
5749
5804
  ev.preventDefault();
5750
5805
  ev.stopPropagation();
5751
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
+ }
5752
5813
  const fileToMove = this._draggedFile || (ev.dataTransfer && ev.dataTransfer.getData('text/plain'));
5753
- const folder = el.dataset.clFolder;
5754
- if (fileToMove && folder !== undefined) {
5814
+ if (fileToMove && el.dataset.clFolder !== undefined) {
5755
5815
  this.moveFile(fileToMove, folder);
5756
5816
  }
5757
5817
  });
5758
5818
  });
5759
5819
 
5760
- // Explorer container drop target (for moving to workspace root)
5820
+ // Explorer container drop target (for moving to workspace root or importing OS files)
5761
5821
  if (!explorerEl._dragBound) {
5762
5822
  explorerEl._dragBound = true;
5763
5823
  explorerEl.addEventListener('dragover', ev => {
5764
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
+ }
5765
5834
  });
5766
5835
  explorerEl.addEventListener('drop', ev => {
5836
+ explorerEl.classList.remove('drag-over');
5767
5837
  if (ev.target.closest && ev.target.closest('.codelab-folder-item')) return;
5768
5838
  ev.preventDefault();
5839
+ if (ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files.length > 0) {
5840
+ this.importDroppedFiles(ev.dataTransfer.files, '');
5841
+ return;
5842
+ }
5769
5843
  const fileToMove = this._draggedFile || (ev.dataTransfer && ev.dataTransfer.getData('text/plain'));
5770
5844
  if (fileToMove) {
5771
5845
  this.moveFile(fileToMove, '');
@@ -6073,7 +6147,7 @@ int main() {
6073
6147
  <button type="button" class="codelab-pkg-btn" data-cl-action="open-packages" title="Manage Dependencies &amp; Built-ins">
6074
6148
  ${CL_ICONS.package}
6075
6149
  <span>Packages</span>
6076
- <span class="codelab-drawer__pill" style="padding:0 5px;font-size:10px;">${pkgBadge}</span>
6150
+ <span class="codelab-drawer__pill">${pkgBadge}</span>
6077
6151
  </button>
6078
6152
  `;
6079
6153
 
@@ -6981,12 +7055,12 @@ int main() {
6981
7055
 
6982
7056
  if (this.drawerTab === 'stdin') {
6983
7057
  bodyEl.innerHTML = `
6984
- <div class="codelab-stdin-panel" style="padding:10px;height:100%;display:flex;flex-direction:column;box-sizing:border-box;">
6985
- <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;font-size:12px;color:var(--cl-fg-muted);">
7058
+ <div class="codelab-stdin-panel">
7059
+ <div class="codelab-stdin-panel__header">
6986
7060
  <span>Standard Input (std::cin / sys.stdin / process.stdin)</span>
6987
- <button type="button" class="codelab-btn codelab-btn--sm" id="cl-stdin-clear-btn" style="padding:2px 8px;font-size:11px;">Clear</button>
7061
+ <button type="button" class="codelab-btn codelab-btn--sm" id="cl-stdin-clear-btn">Clear</button>
6988
7062
  </div>
6989
- <textarea id="cl-stdin-textarea" class="codelab-stdin-textarea" style="flex:1;width:100%;background:var(--cl-bg-input, #1e1e1e);color:var(--cl-fg, #d4d4d4);border:1px solid var(--cl-border, #333);border-radius:4px;padding:8px;font-family:var(--cl-font-mono, monospace);font-size:12px;resize:none;outline:none;box-sizing:border-box;" placeholder="Enter or paste custom stdin here (used by std::cin, sys.stdin, fs.readFileSync(0))...">${escapeHtml(this.customStdin || '')}</textarea>
7063
+ <textarea id="cl-stdin-textarea" class="codelab-stdin-textarea codelab-stdin-panel__textarea" placeholder="Enter or paste custom stdin here (used by std::cin, sys.stdin, fs.readFileSync(0))...">${escapeHtml(this.customStdin || '')}</textarea>
6990
7064
  </div>
6991
7065
  `;
6992
7066
  const ta = bodyEl.querySelector('#cl-stdin-textarea');
@@ -7022,9 +7096,9 @@ int main() {
7022
7096
  <div class="codelab-test-summary ${passed === total ? 'all-pass' : 'has-fail'}">
7023
7097
  <div>
7024
7098
  <strong>${passed === total ? `All ${total} Tests Passing` : `${passed} of ${total} Tests Passing`}</strong>
7025
- ${this.steps.length ? `<span style="margin-left:8px;font-size:12px;opacity:0.8;">(${this.completedSteps.size}/${this.steps.length} Guided Steps Complete)</span>` : ''}
7099
+ ${this.steps.length ? `<span class="cl-ui-meta-inline">(${this.completedSteps.size}/${this.steps.length} Guided Steps Complete)</span>` : ''}
7026
7100
  </div>
7027
- <span style="font-family:var(--cl-font-mono);font-size:12px;">${totalMs} ms</span>
7101
+ <span class="cl-ui-metric">${totalMs} ms</span>
7028
7102
  </div>
7029
7103
  <div class="codelab-test-list">
7030
7104
  ${this.lastTestResults.map(t => `
@@ -7059,7 +7133,7 @@ int main() {
7059
7133
  const html = ansiToHtml ? ansiToHtml(item.text || '') : escapeHtml(item.text || '');
7060
7134
  return `<div class="codelab-log-line ${escapeHtml(item.type || '')}">${html}</div>`;
7061
7135
  }).join('')
7062
- : `<div style="color:var(--cl-fg-muted);font-size:12px;">No output messages yet. Run your code or workspace tasks to inspect output logs.</div>`;
7136
+ : `<div class="cl-ui-muted-note">No output messages yet. Run your code or workspace tasks to inspect output logs.</div>`;
7063
7137
  bodyEl.innerHTML = `<div class="codelab-output-panel" id="cl-output-surface" style="font-size:${termFontPx}px;line-height:1.5;">${linesHtml}</div>`;
7064
7138
  bodyEl.scrollTop = bodyEl.scrollHeight;
7065
7139
  return;
@@ -7250,7 +7324,7 @@ int main() {
7250
7324
  <span style="display:inline-flex;align-items:center;gap:6px;">${CL_ICONS.database}<span>Virtual POSIX File System (${tmpFiles.length} files)</span></span>
7251
7325
  <span>In-Memory VFS</span>
7252
7326
  </div>
7253
- ${tmpFiles.length === 0 ? `<div style="color:var(--cl-fg-muted);font-size:12px;">Run Demo or Tests to inspect virtual files (e.g. /tmp WAL segments &amp; SSTables).</div>` : ''}
7327
+ ${tmpFiles.length === 0 ? `<div class="cl-ui-muted-note">Run Demo or Tests to inspect virtual files (e.g. /tmp WAL segments &amp; SSTables).</div>` : ''}
7254
7328
  ${tmpFiles.map(f => `
7255
7329
  <div class="codelab-vfs-item">
7256
7330
  <div class="codelab-vfs-item__head">
@@ -7268,7 +7342,7 @@ int main() {
7268
7342
  <span style="display:inline-flex;align-items:center;gap:6px;">${CL_ICONS.globe}<span>Virtual Loopback HTTP Trace (${this.lastHttpTrace.length} requests)</span></span>
7269
7343
  <span>127.0.0.1</span>
7270
7344
  </div>
7271
- ${this.lastHttpTrace.length === 0 ? `<div style="color:var(--cl-fg-muted);font-size:12px;">Virtual HTTP loopback requests (e.g., Layer-7 Load Balancer traffic &amp; active health probes) appear here.</div>` : ''}
7345
+ ${this.lastHttpTrace.length === 0 ? `<div class="cl-ui-muted-note">Virtual HTTP loopback requests (e.g., Layer-7 Load Balancer traffic &amp; active health probes) appear here.</div>` : ''}
7272
7346
  ${this.lastHttpTrace.map(req => `
7273
7347
  <div class="codelab-vfs-item">
7274
7348
  <div class="codelab-vfs-item__head">
@@ -7299,13 +7373,13 @@ int main() {
7299
7373
  ? `<div class="codelab-test-summary ${res.verification.passed ? 'all-pass' : 'has-fail'}" style="margin-bottom:10px;">
7300
7374
  <div>
7301
7375
  <strong>${res.verification.passed ? '✓ Step Verification Passed' : '✖ Step Verification Failed'}</strong>
7302
- ${res.verification.message ? `<span style="margin-left:8px;font-size:12px;">${escapeHtml(res.verification.message)}</span>` : ''}
7376
+ ${res.verification.message ? `<span class="cl-ui-meta-inline">${escapeHtml(res.verification.message)}</span>` : ''}
7303
7377
  </div>
7304
- <span style="font-family:var(--cl-font-mono);font-size:12px;">${typeof res.durationMs === 'number' ? `${res.durationMs.toFixed(1)} ms` : ''}</span>
7378
+ <span class="cl-ui-metric">${typeof res.durationMs === 'number' ? `${res.durationMs.toFixed(1)} ms` : ''}</span>
7305
7379
  </div>`
7306
7380
  : '';
7307
7381
  const errHtml = res.error
7308
- ? `<div role="alert" style="padding:10px 12px;margin-bottom:10px;border-radius:6px;border:1px solid rgba(239,68,68,0.45);background:rgba(239,68,68,0.12);color:var(--cl-red,#f87171);font-family:var(--cl-font-mono);font-size:12px;white-space:pre-wrap;">${escapeHtml(typeof res.error === 'string' ? res.error : (res.error.message || String(res.error)))}</div>`
7382
+ ? `<div role="alert" class="cl-ui-alert-error">${escapeHtml(typeof res.error === 'string' ? res.error : (res.error.message || String(res.error)))}</div>`
7309
7383
  : '';
7310
7384
  const cols = Array.isArray(res.columns) ? res.columns : [];
7311
7385
  const rows = Array.isArray(res.rows) ? res.rows : [];
@@ -7339,12 +7413,12 @@ int main() {
7339
7413
  </table>
7340
7414
  </div>`
7341
7415
  : (!res.error
7342
- ? `<div style="color:var(--cl-fg-muted);font-size:12px;padding:8px 2px;">Statement executed (${escapeHtml(rowSummary)}).</div>`
7416
+ ? `<div class="cl-ui-muted-note" style="padding:8px 2px;">Statement executed (${escapeHtml(rowSummary)}).</div>`
7343
7417
  : '');
7344
7418
  const planHtml = res.plan
7345
7419
  ? `<div style="margin-top:10px;">
7346
- <div style="font-size:11px;font-weight:600;color:var(--cl-fg-muted);margin-bottom:4px;text-transform:uppercase;letter-spacing:0.05em;">Query Execution Plan</div>
7347
- <pre style="margin:0;padding:10px;border-radius:6px;border:1px solid var(--cl-border,#262626);background:var(--cl-bg,#0a0a0a);color:var(--cl-fg,#f5f5f5);font-family:var(--cl-font-mono);font-size:11.5px;overflow:auto;">${escapeHtml(typeof res.plan === 'string' ? res.plan : JSON.stringify(res.plan, null, 2))}</pre>
7420
+ <div class="cl-ui-section-label">Query Execution Plan</div>
7421
+ <pre class="cl-ui-code-box">${escapeHtml(typeof res.plan === 'string' ? res.plan : JSON.stringify(res.plan, null, 2))}</pre>
7348
7422
  </div>`
7349
7423
  : '';
7350
7424
  bodyEl.innerHTML = `<div style="padding:10px;">${verificationHtml}${errHtml}${tableHtml}${planHtml}</div>`;
@@ -7363,7 +7437,7 @@ int main() {
7363
7437
  workerStatus: this.runtimeStatusText || 'Idle'
7364
7438
  });
7365
7439
  } else {
7366
- bodyEl.innerHTML = `<div style="padding:14px;color:var(--cl-fg-muted);font-size:12px;">Observability kernel is not initialized.</div>`;
7440
+ bodyEl.innerHTML = `<div class="cl-ui-muted-note" style="padding:14px;">Observability kernel is not initialized.</div>`;
7367
7441
  }
7368
7442
  return;
7369
7443
  }
@@ -7392,18 +7466,34 @@ int main() {
7392
7466
  }
7393
7467
  }
7394
7468
 
7395
- _appendTerminalStream(type = 'stdout', chunk = '') {
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) {
7396
7484
  if (chunk === null || chunk === undefined || chunk === '') return;
7397
7485
  const rawText = String(chunk);
7486
+ const targetSessionId = sessionId || this._activeTerminalSessionId || null;
7487
+ const isTargetActive = !targetSessionId || targetSessionId === this._activeTerminalSessionId;
7398
7488
 
7399
- const activeXterm = this._getActiveXtermEngine();
7400
- if (activeXterm && typeof activeXterm.writeStreamChunk === 'function') {
7489
+ const targetXterm = this._getXtermEngineForSessionId(targetSessionId);
7490
+ if (targetXterm && typeof targetXterm.writeStreamChunk === 'function') {
7401
7491
  try {
7402
- activeXterm.writeStreamChunk(rawText, type);
7492
+ targetXterm.writeStreamChunk(rawText, type);
7403
7493
  } catch (err) {
7404
- this.logger.debug('activeXterm.writeStreamChunk failed.', err);
7494
+ this.logger.debug('targetXterm.writeStreamChunk failed.', err);
7405
7495
  }
7406
- } 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') {
7407
7497
  try {
7408
7498
  this.ptyEngine.writeStreamChunk(rawText, type);
7409
7499
  } catch (err) {
@@ -7411,13 +7501,29 @@ int main() {
7411
7501
  }
7412
7502
  }
7413
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
+
7414
7520
  this._activeStreamType = type;
7415
7521
  const termLogEl = this.container ? this.container.querySelector('#cl-terminal-log') : null;
7416
7522
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
7417
7523
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
7418
7524
 
7419
7525
  // The workbench owns live terminal rendering unless xterm or an attached PTY engine owns the DOM.
7420
- const ptyOwnsDom = Boolean((activeXterm && activeXterm.container) || (this.ptyEngine && this.ptyEngine.container));
7526
+ const ptyOwnsDom = Boolean((targetXterm && targetXterm.container) || (this.ptyEngine && this.ptyEngine.container));
7421
7527
  const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
7422
7528
 
7423
7529
  // Write a single logical line into the live terminal DOM immediately, so output
@@ -7564,11 +7670,16 @@ int main() {
7564
7670
 
7565
7671
  _pushTerminalLog(entry, opts = null) {
7566
7672
  if (!entry) return;
7567
- const activeXterm = this._getActiveXtermEngine();
7568
- if (activeXterm && activeXterm.logs === this.terminalLogs) {
7569
- if (!(opts && opts.fromStream) && typeof activeXterm.writeln === 'function') {
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') {
7570
7681
  try {
7571
- activeXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7682
+ targetXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7572
7683
  } catch (_err) {
7573
7684
  void _err;
7574
7685
  }
@@ -7576,12 +7687,12 @@ int main() {
7576
7687
  this._trimTerminalLogs();
7577
7688
  return;
7578
7689
  }
7579
- if (Array.isArray(this.terminalLogs)) {
7580
- Array.prototype.push.call(this.terminalLogs, entry);
7690
+ if (Array.isArray(targetLogs)) {
7691
+ Array.prototype.push.call(targetLogs, entry);
7581
7692
  }
7582
- if (activeXterm && !(opts && opts.fromStream) && typeof activeXterm.writeln === 'function') {
7693
+ if (targetXterm && !(opts && opts.fromStream) && typeof targetXterm.writeln === 'function') {
7583
7694
  try {
7584
- activeXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7695
+ targetXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7585
7696
  } catch (_err) {
7586
7697
  void _err;
7587
7698
  }
@@ -7672,6 +7783,8 @@ int main() {
7672
7783
 
7673
7784
  _handleInterrupt(opts = null) {
7674
7785
  const fromXterm = Boolean(opts && opts.fromXterm);
7786
+ const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || null;
7787
+ const targetSession = this._getTerminalSessionById(targetSessionId);
7675
7788
  let didInterrupt = false;
7676
7789
  if (this._cloneInFlight || this._activeCloneAbortController) {
7677
7790
  this.cancelClone();
@@ -7688,38 +7801,51 @@ int main() {
7688
7801
  this.logger.debug('cancelWorkerExecution failed.', err);
7689
7802
  }
7690
7803
  }
7691
- const isCommandRunning = Boolean(this.isRunning || this._activeCommandAbortController || cancelledWorker);
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)));
7692
7809
  const cwdShort = (this.cwd || '/workspace').replace(/^\/workspace\/?/, '') || '~';
7693
7810
  const promptLabel = this.inRepl ? '> ' : `codelab:${cwdShort}$`;
7694
7811
 
7695
7812
  if (isCommandRunning) {
7696
7813
  didInterrupt = true;
7697
- if (this._activeCommandAbortController) {
7814
+ if (activeAbort) {
7698
7815
  try {
7699
- this._activeCommandAbortController.abort('SIGINT');
7816
+ activeAbort.abort('SIGINT');
7700
7817
  } catch (err) {
7701
7818
  this.logger.debug('AbortController.abort failed.', err);
7702
7819
  }
7703
- this._activeCommandAbortController = null;
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');
7704
7833
  }
7705
-
7706
- this.isRunning = false;
7707
- this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
7708
7834
  this._updateRunStateUI();
7709
7835
 
7710
7836
  this._flushTerminalStream();
7711
7837
  if (!fromXterm) {
7712
- this._pushTerminalLog({ type: 'stdout', text: '^C' });
7838
+ this._pushTerminalLog({ type: 'stdout', text: '^C' }, { sessionId: targetSessionId });
7713
7839
  }
7714
7840
  } else {
7715
7841
  if (this.inRepl) {
7716
7842
  this.inRepl = false;
7717
7843
  if (!fromXterm) {
7718
- this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' });
7844
+ this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' }, { sessionId: targetSessionId });
7719
7845
  }
7720
7846
  } else if (!fromXterm) {
7721
7847
  const currentInput = (this._ptyInputBeforeCursor || '') + (this._ptyInputAfterCursor || '');
7722
- this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` });
7848
+ this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` }, { sessionId: targetSessionId });
7723
7849
  }
7724
7850
  }
7725
7851
 
@@ -8142,8 +8268,8 @@ int main() {
8142
8268
  if (servers.length === 0) {
8143
8269
  serversHtml = `
8144
8270
  <div class="codelab-ports-empty">
8145
- <p style="margin:0 0 6px 0;font-weight:500;">No active port listeners</p>
8146
- <span style="font-size:12px;color:var(--cl-fg-muted);">
8271
+ <p class="cl-ui-body-p">No active port listeners</p>
8272
+ <span class="cl-ui-muted-note">
8147
8273
  Run an HTTP or WebSocket server in the terminal (e.g. <code>node server.js &amp;</code> or <code>bun run server.ts &amp;</code>) to bind a virtual port.
8148
8274
  </span>
8149
8275
  </div>
@@ -8266,7 +8392,7 @@ int main() {
8266
8392
  <div class="codelab-panel-section">
8267
8393
  <div class="codelab-section-title">
8268
8394
  <span>${CL_ICONS.send || ''} Mini HTTP Client</span>
8269
- <span style="font-size:11px;color:var(--cl-fg-muted);">Virtual Loopback (127.0.0.1)</span>
8395
+ <span class="cl-ui-muted-xs">Virtual Loopback (127.0.0.1)</span>
8270
8396
  </div>
8271
8397
  <div class="codelab-http-client">
8272
8398
  <div class="codelab-http-url-bar">
@@ -8415,7 +8541,7 @@ int main() {
8415
8541
 
8416
8542
  topologyHtml = `
8417
8543
  <div class="codelab-topo-bar">
8418
- <div class="codelab-topo-nodes">${nodePills || '<span style="font-size:11px;color:var(--cl-fg-muted);">No listening servers</span>'}</div>
8544
+ <div class="codelab-topo-nodes">${nodePills || '<span class="cl-ui-muted-xs">No listening servers</span>'}</div>
8419
8545
  ${edgePills ? `<div class="codelab-topo-edges">${edgePills}</div>` : ''}
8420
8546
  </div>
8421
8547
  `;
@@ -8467,8 +8593,8 @@ int main() {
8467
8593
  <td><span class="codelab-method-badge codelab-method-${(t.method || 'GET').toLowerCase()}">${escapeHtml(t.method || 'GET')}</span></td>
8468
8594
  <td class="codelab-net-path" title="${escapeHtml(t.url || '/')}">${escapeHtml(t.url || '/')}</td>
8469
8595
  <td><code>${escapeHtml(hopLabel)}</code></td>
8470
- <td style="white-space:nowrap;font-family:var(--cl-font-mono);font-size:11.5px;">${(t.durationMs || 0).toFixed(1)} ms</td>
8471
- <td style="white-space:nowrap;font-family:var(--cl-font-mono);font-size:11.5px;">${t.size != null ? t.size : 0} B</td>
8596
+ <td class="cl-ui-metric-cell">${(t.durationMs || 0).toFixed(1)} ms</td>
8597
+ <td class="cl-ui-metric-cell">${t.size != null ? t.size : 0} B</td>
8472
8598
  <td class="codelab-waterfall-cell">
8473
8599
  <div class="codelab-waterfall-track">
8474
8600
  <div class="codelab-waterfall-bar" style="width:${widthPct}%;"></div>
@@ -8583,7 +8709,7 @@ int main() {
8583
8709
  <option value="5xx" ${filter.status === '5xx' ? 'selected' : ''}>5xx / Network Fault</option>
8584
8710
  </select>
8585
8711
  <button type="button" class="codelab-btn" data-cl-action="clear-net-traces">Clear</button>
8586
- <span id="cl-net-count" style="margin-left:auto;font-size:11.5px;color:var(--cl-fg-muted);">${filtered.length} of ${traces.length} requests</span>
8712
+ <span id="cl-net-count" class="cl-ui-net-count">${filtered.length} of ${traces.length} requests</span>
8587
8713
  </div>
8588
8714
  <div class="codelab-net-main">
8589
8715
  <div class="codelab-net-table-container">
@@ -8665,8 +8791,8 @@ int main() {
8665
8791
  <td><span class="codelab-method-badge codelab-method-${(t.method || 'GET').toLowerCase()}">${escapeHtml(t.method || 'GET')}</span></td>
8666
8792
  <td class="codelab-net-path" title="${escapeHtml(t.url || '/')}">${escapeHtml(t.url || '/')}</td>
8667
8793
  <td><code>${escapeHtml(hopLabel)}</code></td>
8668
- <td style="white-space:nowrap;font-family:var(--cl-font-mono);font-size:11.5px;">${(t.durationMs || 0).toFixed(1)} ms</td>
8669
- <td style="white-space:nowrap;font-family:var(--cl-font-mono);font-size:11.5px;">${t.size != null ? t.size : 0} B</td>
8794
+ <td class="cl-ui-metric-cell">${(t.durationMs || 0).toFixed(1)} ms</td>
8795
+ <td class="cl-ui-metric-cell">${t.size != null ? t.size : 0} B</td>
8670
8796
  <td class="codelab-waterfall-cell">
8671
8797
  <div class="codelab-waterfall-track">
8672
8798
  <div class="codelab-waterfall-bar" style="width:${widthPct}%;"></div>
@@ -8868,13 +8994,13 @@ int main() {
8868
8994
  if (this._activeTerminalSessionId !== session.id) {
8869
8995
  this.switchTerminalSession(session.id);
8870
8996
  }
8871
- return this._handleReplCommand(cmd, { skipEcho: true });
8997
+ return this._handleReplCommand(cmd, { skipEcho: true, sessionId: session.id });
8872
8998
  },
8873
8999
  onInterrupt: () => {
8874
9000
  if (this._activeTerminalSessionId !== session.id) {
8875
9001
  this.switchTerminalSession(session.id);
8876
9002
  }
8877
- this._handleInterrupt({ fromXterm: true });
9003
+ this._handleInterrupt({ fromXterm: true, sessionId: session.id });
8878
9004
  },
8879
9005
  getCompletions: (buf, cur) => {
8880
9006
  const slice = String(buf || '').slice(0, typeof cur === 'number' ? cur : String(buf || '').length);
@@ -9753,7 +9879,7 @@ int main() {
9753
9879
  this._renderDrawerBody();
9754
9880
 
9755
9881
  try {
9756
- const res = await this.shell.execute(`serve ${rootDir}`, {});
9882
+ const res = await this.shell.execute(`serve ${rootDir}`, { isBackground: true });
9757
9883
  if (res && res.stdout) this._pushTerminalLog({ type: 'stdout', text: res.stdout.replace(/\n$/, '') });
9758
9884
  if (res && res.stderr) this._pushTerminalLog({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
9759
9885
  } catch (err) {
@@ -13800,6 +13926,7 @@ int main() {
13800
13926
  { id: 'toggle-guide', label: 'View: Toggle Guide Sidebar', action: () => this.toggleGuide() },
13801
13927
  { id: 'toggle-drawer', label: 'View: Toggle Panel Visibility', shortcut: '⌘J', action: () => this.togglePanel() },
13802
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() },
13803
13930
  { id: 'toggle-fullscreen', label: 'View: Toggle Fullscreen Workbench', action: () => this.toggleFullscreen() },
13804
13931
  { id: 'search-workspace', label: 'Search: Find & Replace Across Files...', shortcut: '⇧⌘F', action: () => this.openSearchView() },
13805
13932
  { id: 'open-scm', label: 'Git: Source Control (Status, Stage & Commit)...', shortcut: '⌃⇧G', action: () => this.openScmView() },
@@ -14002,7 +14129,7 @@ int main() {
14002
14129
  type: 'symbol',
14003
14130
  id: `${activeTarget}:${sym.line}:${sym.name}`,
14004
14131
  label: `${sym.name} (${sym.kind})`,
14005
- labelHtml: `${escapeHtml(sym.name)} <span style="opacity:0.6;font-size:11px;">${escapeHtml(sym.kind)} · Ln ${sym.line}</span>`,
14132
+ labelHtml: `${escapeHtml(sym.name)} <span class="cl-ui-palette-sub">${escapeHtml(sym.kind)} · Ln ${sym.line}</span>`,
14006
14133
  shortcut: activeTarget || '',
14007
14134
  action: () => {
14008
14135
  if (activeTarget) {
@@ -14029,7 +14156,7 @@ int main() {
14029
14156
  type: 'symbol',
14030
14157
  id: `${file}:${sym.line}:${sym.name}`,
14031
14158
  label: `${sym.name} — ${file}`,
14032
- labelHtml: `${escapeHtml(sym.name)} <span style="opacity:0.6;font-size:11px;">${escapeHtml(file)}:${sym.line}</span>`,
14159
+ labelHtml: `${escapeHtml(sym.name)} <span class="cl-ui-palette-sub">${escapeHtml(file)}:${sym.line}</span>`,
14033
14160
  shortcut: sym.kind,
14034
14161
  action: () => {
14035
14162
  this.openFile(file);
@@ -14897,6 +15024,91 @@ int main() {
14897
15024
  if (this.editor) setTimeout(() => this.editor.layout(), 50);
14898
15025
  }
14899
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
+
14900
15112
  stopExecution() {
14901
15113
  this._handleInterrupt();
14902
15114
  }
@@ -15065,37 +15277,37 @@ int main() {
15065
15277
  <button type="button" class="codelab-btn" data-cl-action="close-modal">Close (Esc)</button>
15066
15278
  </div>
15067
15279
  </div>
15068
- <div class="codelab-modal__body" style="font-family:var(--cl-font-sans);">
15069
- <div style="display:flex;gap:8px;margin-bottom:16px;">
15070
- <input id="cl-pkg-input" type="text" placeholder="Add npm package (e.g. zod, lru-cache, nanoid@5.0.0)..." style="flex:1;height:32px;padding:0 10px;background:var(--cl-bg);border:1px solid var(--cl-border-strong);border-radius:var(--cl-radius-sm);color:var(--cl-fg);font-family:var(--cl-font-mono);font-size:12px;outline:none;" />
15280
+ <div class="codelab-modal__body">
15281
+ <div class="cl-ui-form-row">
15282
+ <input id="cl-pkg-input" class="cl-ui-input cl-ui-input--mono" type="text" placeholder="Add npm package (e.g. zod, lru-cache, nanoid@5.0.0)..." />
15071
15283
  <button type="button" class="codelab-btn codelab-btn--primary" data-cl-action="add-package">+ Add Dependency</button>
15072
15284
  </div>
15073
15285
  <div style="margin-bottom:16px;">
15074
- <div style="font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.06em;color:var(--cl-fg-muted);margin-bottom:8px;">
15286
+ <div class="cl-ui-section-label">
15075
15287
  External NPM Packages (${pkgs.length})
15076
15288
  </div>
15077
15289
  ${pkgs.length === 0 ? `
15078
- <div style="padding:12px;border:1px solid var(--cl-border);border-radius:var(--cl-radius-sm);background:var(--cl-bg);color:var(--cl-fg-muted);font-size:12.5px;">
15290
+ <div class="cl-ui-card-note">
15079
15291
  No external npm packages imported yet. Any <code>import ... from 'pkg'</code> or <code>require('pkg')</code> in your code is automatically resolved via <strong>jsDelivr</strong> when you run or test.
15080
15292
  </div>
15081
15293
  ` : `
15082
- <div style="display:flex;flex-direction:column;gap:6px;">
15294
+ <div class="cl-ui-stack-xs">
15083
15295
  ${pkgs.map(p => `
15084
- <div style="display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border:1px solid var(--cl-border);border-radius:var(--cl-radius-sm);background:var(--cl-bg);font-family:var(--cl-font-mono);font-size:12px;">
15085
- <span style="color:var(--cl-fg);font-weight:600;">${escapeHtml(p.name)}</span>
15086
- <span style="color:var(--cl-accent);">${escapeHtml(p.version)} · jsDelivr</span>
15296
+ <div class="cl-ui-pkg-row">
15297
+ <span class="cl-ui-pkg-row__name">${escapeHtml(p.name)}</span>
15298
+ <span class="cl-ui-pkg-row__meta">${escapeHtml(p.version)} · jsDelivr</span>
15087
15299
  </div>
15088
15300
  `).join('')}
15089
15301
  </div>
15090
15302
  `}
15091
15303
  </div>
15092
15304
  <div>
15093
- <div style="font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.06em;color:var(--cl-fg-muted);margin-bottom:8px;">
15305
+ <div class="cl-ui-section-label">
15094
15306
  Built-in Virtual Node.js Modules (Zero-Latency In-Memory VFS)
15095
15307
  </div>
15096
- <div style="display:flex;flex-wrap:wrap;gap:6px;">
15308
+ <div class="cl-ui-chip-wrap">
15097
15309
  ${builtins.map(b => `
15098
- <span style="padding:3px 8px;border:1px solid var(--cl-border);border-radius:4px;background:var(--cl-bg);font-family:var(--cl-font-mono);font-size:11px;color:var(--cl-fg-muted);">${b}</span>
15310
+ <span class="cl-ui-chip">${b}</span>
15099
15311
  `).join('')}
15100
15312
  </div>
15101
15313
  </div>
@@ -17623,31 +17835,56 @@ int main() {
17623
17835
  );
17624
17836
 
17625
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);
17626
17840
  const abortCtrl = new AbortController();
17627
- this._activeCommandAbortController = abortCtrl;
17628
- this.isRunning = true;
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
+ }
17629
17849
  this._updateRunStateUI();
17630
17850
  let streamedStdout = false;
17631
17851
  let streamedStderr = false;
17632
17852
 
17633
17853
  try {
17634
17854
  this._syncFilesToShellVfs();
17635
- 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
+ }
17636
17862
  const shellRes = await this.shell.execute(trimmed, {
17637
17863
  onStdout: (c) => {
17638
17864
  streamedStdout = true;
17639
- this._appendTerminalStream('stdout', c);
17865
+ this._appendTerminalStream('stdout', c, targetSessionId);
17640
17866
  },
17641
17867
  onStderr: (c) => {
17642
17868
  streamedStderr = true;
17643
- this._appendTerminalStream('stderr', c);
17869
+ this._appendTerminalStream('stderr', c, targetSessionId);
17644
17870
  },
17645
17871
  onRequestStdin: (promptText) => this._requestInteractiveTerminalStdin(promptText, abortCtrl.signal),
17646
17872
  signal: abortCtrl.signal
17647
17873
  });
17648
- this._flushTerminalStream();
17874
+ if (targetSessionId === this._activeTerminalSessionId) {
17875
+ this._flushTerminalStream();
17876
+ }
17649
17877
  const aborted = this._isAbortResult(shellRes, abortCtrl.signal);
17650
- this.cwd = this.shell.cwd || this.cwd;
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
+ }
17651
17888
  this._syncVfsSnapshot(null, true);
17652
17889
  if (/^\s*git\b/.test(trimmed) || (this.shell && this.shell.gitState && this.shell.gitState.initialized)) {
17653
17890
  this._saveState();
@@ -17660,39 +17897,56 @@ int main() {
17660
17897
  this._updateStatusBar();
17661
17898
 
17662
17899
  if (shellRes && shellRes.clear) {
17663
- this._clearTerminalLogs();
17900
+ if (targetSessionId === this._activeTerminalSessionId) {
17901
+ this._clearTerminalLogs();
17902
+ } else if (targetSession) {
17903
+ targetSession.logs = [];
17904
+ }
17664
17905
  this._renderDrawerBody();
17665
17906
  return;
17666
17907
  }
17667
17908
  if (shellRes && shellRes.interactiveRepl) {
17668
- this.inRepl = true;
17909
+ if (targetSession) targetSession.inRepl = true;
17910
+ if (targetSessionId === this._activeTerminalSessionId) {
17911
+ this.inRepl = true;
17912
+ }
17669
17913
  if (shellRes.stdout && !streamedStdout) {
17670
- this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
17914
+ this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') }, { sessionId: targetSessionId });
17671
17915
  }
17672
17916
  this._renderDrawerBody();
17673
17917
  return;
17674
17918
  }
17675
17919
 
17676
17920
  if (!aborted && shellRes && shellRes.stdout && !streamedStdout) {
17677
- this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
17921
+ this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') }, { sessionId: targetSessionId });
17678
17922
  }
17679
17923
  if (!aborted && shellRes && shellRes.stderr && !streamedStderr) {
17680
- this._pushTerminalLog({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') });
17924
+ this._pushTerminalLog({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') }, { sessionId: targetSessionId });
17681
17925
  }
17682
17926
  this._renderDrawerBody();
17683
17927
  return;
17684
17928
  } catch (err) {
17685
- this._flushTerminalStream();
17929
+ if (targetSessionId === this._activeTerminalSessionId) {
17930
+ this._flushTerminalStream();
17931
+ }
17686
17932
  if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
17687
- this._pushTerminalLog({ type: 'stderr', text: formatErrorText(err) });
17933
+ this._pushTerminalLog({ type: 'stderr', text: formatErrorText(err) }, { sessionId: targetSessionId });
17688
17934
  }
17689
17935
  this._renderDrawerBody();
17690
17936
  return;
17691
17937
  } finally {
17938
+ if (targetSession) {
17939
+ if (targetSession.abortController === abortCtrl) {
17940
+ targetSession.abortController = null;
17941
+ }
17942
+ targetSession.isRunning = false;
17943
+ }
17692
17944
  if (this._activeCommandAbortController === abortCtrl) {
17693
17945
  this._activeCommandAbortController = null;
17694
17946
  }
17695
- this.isRunning = false;
17947
+ if (targetSessionId === this._activeTerminalSessionId) {
17948
+ this.isRunning = false;
17949
+ }
17696
17950
  this._updateRunStateUI();
17697
17951
  }
17698
17952
  }
@@ -18226,7 +18480,7 @@ int main() {
18226
18480
  <button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="close-modal" title="Close" aria-label="Close">&times;</button>
18227
18481
  </div>
18228
18482
  <div class="codelab-modal__body">
18229
- <p id="cl-discard-modal-desc" style="margin:0 0 14px;font-size:13px;line-height:1.5;">${escapeHtml(desc)}</p>
18483
+ <p id="cl-discard-modal-desc" class="cl-ui-modal-desc">${escapeHtml(desc)}</p>
18230
18484
  <div style="display:flex;justify-content:flex-end;gap:8px;">
18231
18485
  <button type="button" class="codelab-btn" id="cl-discard-cancel-btn" data-cl-action="close-modal">Cancel</button>
18232
18486
  <button type="button" class="codelab-btn codelab-btn--danger" id="cl-discard-confirm-btn">Discard Changes</button>
@@ -19329,6 +19583,7 @@ int main() {
19329
19583
  label: 'Appearance',
19330
19584
  submenu: [
19331
19585
  { label: 'Full Screen', cmd: 'view:fullscreen' },
19586
+ { label: 'Zen Mode', cmd: 'view:zen-mode' },
19332
19587
  { label: 'Move Primary Side Bar Left / Right', cmd: 'view:toggle-sidebar-side' },
19333
19588
  { label: 'Toggle Status Bar', cmd: 'view:toggle-statusbar' },
19334
19589
  { divider: true },
@@ -19605,6 +19860,8 @@ int main() {
19605
19860
  this.togglePanel();
19606
19861
  } else if (cmd === 'view:fullscreen') {
19607
19862
  this.toggleFullscreen();
19863
+ } else if (cmd === 'view:zen-mode') {
19864
+ this.toggleZenMode();
19608
19865
  } else if (cmd === 'view:toggle-sidebar-side') {
19609
19866
  if (this.configuration && typeof this.configuration.setUserSetting === 'function') {
19610
19867
  const cur = this.configuration.get('workbench.sidebar.defaultLocation', 'left');
@@ -19758,12 +20015,12 @@ int main() {
19758
20015
  this._captureModalReturnFocus();
19759
20016
  const rowsHtml = list.length > 0
19760
20017
  ? list.map((ws) => `
19761
- <button type="button" class="codelab-recent-ws-item" data-cl-workspace="${escapeHtml(ws.labId)}" style="display:flex;width:100%;align-items:center;justify-content:space-between;padding:8px 10px;border:1px solid var(--cl-border);border-radius:var(--cl-radius-sm);background:var(--cl-surface);color:var(--cl-fg);cursor:pointer;text-align:left;">
20018
+ <button type="button" class="codelab-recent-ws-item" data-cl-workspace="${escapeHtml(ws.labId)}">
19762
20019
  <span>
19763
20020
  <strong>${escapeHtml(ws.title || ws.labId)}</strong>
19764
- ${ws.labId === this.labId ? '<span style="opacity:0.7;margin-left:6px;">(Current)</span>' : ''}
20021
+ ${ws.labId === this.labId ? '<span class="cl-ui-meta-inline">(Current)</span>' : ''}
19765
20022
  </span>
19766
- <code style="font-size:11px;opacity:0.75;">${escapeHtml(ws.labId)}</code>
20023
+ <code class="cl-ui-chip">${escapeHtml(ws.labId)}</code>
19767
20024
  </button>
19768
20025
  `).join('')
19769
20026
  : '<p style="margin:0;color:var(--cl-fg-muted);">No saved workspaces found yet.</p>';
@@ -20231,8 +20488,8 @@ int main() {
20231
20488
  <button type="button" class="codelab-btn" data-cl-action="close-modal">Close (Esc)</button>
20232
20489
  </div>
20233
20490
  <div class="codelab-modal__body">
20234
- <div style="display:grid;grid-template-columns:1fr auto;gap:6px 16px;font-size:12px;">
20235
- ${rows.map(([label, kbd]) => `<span>${escapeHtml(label)}</span><kbd style="font-family:var(--cl-font-mono);">${escapeHtml(kbd)}</kbd>`).join('')}
20491
+ <div class="cl-ui-shortcuts-grid">
20492
+ ${rows.map(([label, kbd]) => `<span>${escapeHtml(label)}</span><kbd class="cl-ui-kbd">${escapeHtml(kbd)}</kbd>`).join('')}
20236
20493
  </div>
20237
20494
  </div>
20238
20495
  </div>
@@ -20253,9 +20510,9 @@ int main() {
20253
20510
  <span>About CodeLab</span>
20254
20511
  <button type="button" class="codelab-btn" data-cl-action="close-modal">Close (Esc)</button>
20255
20512
  </div>
20256
- <div class="codelab-modal__body" style="font-size:13px;line-height:1.5;">
20257
- <p style="margin:0 0 8px;"><strong>@innovatorved/code-lab</strong> — Full-featured in-browser IDE &amp; runtime workbench.</p>
20258
- <p style="margin:0;color:var(--cl-fg-muted);font-size:12px;">Node.js v22 Worker · TypeScript 5.x · C++20 WASI · Python 3.12 WASI · SQLite / PostgreSQL · Git</p>
20513
+ <div class="codelab-modal__body">
20514
+ <p class="cl-ui-body-p"><strong>@innovatorved/code-lab</strong> — Full-featured in-browser IDE &amp; runtime workbench.</p>
20515
+ <p class="cl-ui-muted-note">Node.js v22 Worker · TypeScript 5.x · C++20 WASI · Python 3.12 WASI · SQLite / PostgreSQL · Git</p>
20259
20516
  </div>
20260
20517
  </div>
20261
20518
  </dialog>
@@ -20300,17 +20557,33 @@ int main() {
20300
20557
  }).join('');
20301
20558
  }
20302
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
+
20303
20569
  _saveActiveTerminalSessionState() {
20304
20570
  if (!Array.isArray(this._terminalSessions)) return;
20305
20571
  const active = this._terminalSessions.find((s) => s.id === this._activeTerminalSessionId);
20306
20572
  if (!active) return;
20307
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
+ }
20308
20577
  active.inRepl = Boolean(this.inRepl);
20309
20578
  active.replLang = this.replLang || 'node';
20310
20579
  active.replHistory = Array.isArray(this.replHistory) ? this.replHistory.slice() : [];
20311
20580
  active.replHistoryIdx = typeof this.replHistoryIdx === 'number' ? this.replHistoryIdx : -1;
20312
20581
  active.beforeCursor = this._ptyInputBeforeCursor || '';
20313
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
+ }
20314
20587
  if (Array.isArray(this.terminalLogs)) {
20315
20588
  active.logs = this.terminalLogs;
20316
20589
  }
@@ -20324,9 +20597,10 @@ int main() {
20324
20597
  this.cwd = target.cwd || '/workspace';
20325
20598
  if (this.shell) {
20326
20599
  this.shell.cwd = this.cwd;
20327
- if (this.shell.env && typeof this.shell.env === 'object') {
20328
- this.shell.env.PWD = this.cwd;
20600
+ if (!target.env || typeof target.env !== 'object') {
20601
+ target.env = { ...this._getBaseShellEnv(), PWD: this.cwd };
20329
20602
  }
20603
+ this.shell.env = { ...target.env, PWD: this.cwd };
20330
20604
  }
20331
20605
  this.inRepl = Boolean(target.inRepl);
20332
20606
  this.replLang = target.replLang || 'node';
@@ -20334,15 +20608,22 @@ int main() {
20334
20608
  this.replHistoryIdx = typeof target.replHistoryIdx === 'number' ? target.replHistoryIdx : -1;
20335
20609
  this._ptyInputBeforeCursor = target.beforeCursor || '';
20336
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
+ }
20337
20616
  }
20338
20617
 
20339
20618
  _ensureTerminalSessions() {
20340
20619
  if (!Array.isArray(this._terminalSessions) || this._terminalSessions.length === 0) {
20620
+ const initCwd = this.cwd || (this.shell && this.shell.cwd) || '/workspace';
20341
20621
  this._terminalSessions = [
20342
20622
  {
20343
20623
  id: 'session-1',
20344
20624
  name: 'bash-1',
20345
- cwd: this.cwd || (this.shell && this.shell.cwd) || '/workspace',
20625
+ cwd: initCwd,
20626
+ env: { ...this._getBaseShellEnv(), PWD: initCwd },
20346
20627
  logs: Array.isArray(this.terminalLogs) ? this.terminalLogs : (this.terminalLogs = []),
20347
20628
  inRepl: Boolean(this.inRepl),
20348
20629
  replLang: this.replLang || 'node',
@@ -20380,6 +20661,7 @@ int main() {
20380
20661
  id,
20381
20662
  name: label,
20382
20663
  cwd: '/workspace',
20664
+ env: { ...this._getBaseShellEnv(), PWD: '/workspace' },
20383
20665
  logs: [],
20384
20666
  inRepl: false,
20385
20667
  replLang: 'node',
@@ -20452,6 +20734,11 @@ int main() {
20452
20734
 
20453
20735
  this._saveActiveTerminalSessionState();
20454
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
+ }
20455
20742
  if (this._xtermEngines instanceof Map && removed) {
20456
20743
  const oldEng = this._xtermEngines.get(removed.id);
20457
20744
  if (oldEng && typeof oldEng.destroy === 'function') {
@@ -20747,8 +21034,8 @@ int main() {
20747
21034
  <span id="cl-clone-modal-title" style="display:inline-flex;align-items:center;gap:6px;">${CL_ICONS.gitBranch || CL_ICONS.terminal || CL_ICONS.folder}<span>Clone Public GitHub Repository</span></span>
20748
21035
  <button type="button" class="codelab-btn" id="cl-clone-close-btn" data-cl-action="close-modal" aria-label="Close">✕</button>
20749
21036
  </div>
20750
- <div class="codelab-modal__body" style="font-family:var(--cl-font-sans);">
20751
- <p id="cl-clone-modal-desc" style="margin:0 0 12px;font-size:12.5px;color:var(--cl-fg-muted);line-height:1.45;">
21037
+ <div class="codelab-modal__body">
21038
+ <p id="cl-clone-modal-desc" class="cl-ui-modal-desc">
20752
21039
  Enter a public GitHub repository URL or <code>owner/repo</code> slug. Files are cloned transactionally into the Virtual Filesystem (VFS).
20753
21040
  </p>
20754
21041
  <form id="cl-clone-repo-form" class="codelab-clone-form" novalidate>
@@ -21705,6 +21992,8 @@ int main() {
21705
21992
  openSettings(opts) { if (this._instance) this._instance.openSettings(opts); }
21706
21993
  closeSettings() { if (this._instance) this._instance.closeSettings(); }
21707
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([]); }
21708
21997
  runSql(mode, payload) { return this._instance ? this._instance.runSql(mode, payload) : Promise.resolve(null); }
21709
21998
  setSqlSchema(schema) { if (this._instance) this._instance.setSqlSchema(schema); return this; }
21710
21999
  setSqlDialect(dialect) { if (this._instance) this._instance.setSqlDialect(dialect); return this; }