@innovatorved/code-lab 0.1.2 → 0.1.3

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/src/workbench.ts CHANGED
@@ -1172,6 +1172,9 @@ declare module 'bun:sqlite' {
1172
1172
  this.folders = new Set(this.savedState?.folders || []);
1173
1173
  this.collapsedFolders = new Set(this.savedState?.collapsedFolders || []);
1174
1174
  this.explorerFolder = this.savedState?.explorerFolder || ''; // '' = workspace root, else folder path scope
1175
+ this.explorerWidth = (typeof this.savedState?.explorerWidth === 'number' && this.savedState.explorerWidth >= 120)
1176
+ ? this.savedState.explorerWidth
1177
+ : 196;
1175
1178
  this.folderSwitcherOpen = false;
1176
1179
  this.creatingItem = null; // { type: 'file' | 'folder', parentFolder: string } | null
1177
1180
  this.renamingItem = null;
@@ -1509,7 +1512,8 @@ declare module 'bun:sqlite' {
1509
1512
  activeFile: this.activeFile,
1510
1513
  folders: Array.from(this.folders || []),
1511
1514
  collapsedFolders: Array.from(this.collapsedFolders || []),
1512
- explorerFolder: this.explorerFolder || ''
1515
+ explorerFolder: this.explorerFolder || '',
1516
+ explorerWidth: typeof this.explorerWidth === 'number' ? this.explorerWidth : undefined
1513
1517
  };
1514
1518
  this.savedState = state;
1515
1519
  if (this.options && this.options.persistState === false) {
@@ -1690,6 +1694,13 @@ declare module 'bun:sqlite' {
1690
1694
  if (stopBtn) {
1691
1695
  stopBtn.style.display = this.isRunning ? 'inline-flex' : 'none';
1692
1696
  }
1697
+ const ctrlCBtn = this.container.querySelector('#cl-ctrl-c-btn');
1698
+ if (ctrlCBtn) {
1699
+ ctrlCBtn.classList.toggle('is-running', Boolean(this.isRunning));
1700
+ ctrlCBtn.title = this.isRunning
1701
+ ? 'Send Ctrl+C — interrupt the running command'
1702
+ : 'Send Ctrl+C (clears the current input line)';
1703
+ }
1693
1704
  this.container.querySelectorAll('[data-cl-action="run-demo"], [data-cl-action="run-tests"], [data-cl-action="verify-step"]').forEach(btn => {
1694
1705
  btn.disabled = this.isRunning;
1695
1706
  });
@@ -1704,8 +1715,9 @@ declare module 'bun:sqlite' {
1704
1715
  const themeAttr = this.themeOption !== 'auto' ? `data-theme="${escapeHtml(this.themeOption)}"` : '';
1705
1716
  const brandLabel = (this.title && this.title !== 'custom-lab' && this.title !== this.labId) ? this.title : 'code-lab';
1706
1717
  const isGuideCollapsed = !this.hasGuidedLab || this.mode === 'sandbox' || !this.steps.length;
1718
+ const explorerStyle = `style="--cl-explorer-width:${Math.round(this.explorerWidth || 196)}px"`;
1707
1719
  this.container.innerHTML = `
1708
- <div class="codelab codelab-workbench ${isGuideCollapsed ? 'guide-collapsed' : ''}" id="codelab-${escapeHtml(this.labId)}" ${themeAttr}>
1720
+ <div class="codelab codelab-workbench ${isGuideCollapsed ? 'guide-collapsed' : ''}" id="codelab-${escapeHtml(this.labId)}" ${themeAttr} ${explorerStyle}>
1709
1721
  <!-- Top Bar -->
1710
1722
  <div class="codelab-topbar codelab-toolbar">
1711
1723
  <div class="codelab-topbar__left">
@@ -1821,6 +1833,9 @@ declare module 'bun:sqlite' {
1821
1833
  <div class="codelab-explorer__list" id="cl-explorer-list"></div>
1822
1834
  </div>
1823
1835
 
1836
+ <!-- Explorer Resize Splitter -->
1837
+ <div class="codelab-splitter-files" id="cl-splitter-files" role="separator" aria-orientation="vertical" title="Drag to resize file explorer (double-click to reset)"></div>
1838
+
1824
1839
  <!-- Editor Column -->
1825
1840
  <div class="codelab-editor-col">
1826
1841
  <div class="codelab-tabs codelab-file-tabs" id="cl-file-tabs" role="tablist" aria-label="Open Files"></div>
@@ -1874,6 +1889,7 @@ declare module 'bun:sqlite' {
1874
1889
  </button>
1875
1890
  </div>
1876
1891
  <div style="display:flex;align-items:center;gap:6px;">
1892
+ <button type="button" class="codelab-btn codelab-btn--icon codelab-btn--ctrl-c" id="cl-ctrl-c-btn" data-cl-action="interrupt" title="Send Ctrl+C — interrupt a running command" aria-label="Send Ctrl+C interrupt" style="padding:2px 8px;font-size:11px;font-family:var(--cl-font-mono);">Ctrl+C</button>
1877
1893
  <button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="clear-terminal" title="Clear Output" style="padding:2px 6px;font-size:11px;">Clear</button>
1878
1894
  <button type="button" class="codelab-btn codelab-btn--icon" data-cl-action="toggle-drawer" title="Minimize/Expand Drawer" aria-label="Minimize or Expand Drawer" style="padding:2px 6px;font-size:11px;">${CL_ICONS.chevronsUpDown}</button>
1879
1895
  </div>
@@ -3015,10 +3031,10 @@ declare module 'bun:sqlite' {
3015
3031
  this._ptyInputAfterCursor = '';
3016
3032
  this._updatePtyActiveLine();
3017
3033
  }
3018
- } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'c') {
3034
+ } else if (e.ctrlKey && !e.metaKey && e.key.toLowerCase() === 'c') {
3019
3035
  e.preventDefault();
3020
3036
  this._handleInterrupt();
3021
- } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'd') {
3037
+ } else if (e.ctrlKey && !e.metaKey && e.key.toLowerCase() === 'd') {
3022
3038
  e.preventDefault();
3023
3039
  if (this.inRepl) {
3024
3040
  this.inRepl = false;
@@ -3027,7 +3043,7 @@ declare module 'bun:sqlite' {
3027
3043
  const nextInput = this.container.querySelector('#cl-repl-input');
3028
3044
  if (nextInput && typeof nextInput.focus === 'function') nextInput.focus();
3029
3045
  }
3030
- } else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'l') {
3046
+ } else if (e.ctrlKey && !e.metaKey && e.key.toLowerCase() === 'l') {
3031
3047
  e.preventDefault();
3032
3048
  this.terminalLogs = [];
3033
3049
  this._renderDrawerBody();
@@ -4772,41 +4788,18 @@ declare module 'bun:sqlite' {
4772
4788
 
4773
4789
  _renderEmptyEditorContent(emptyEl) {
4774
4790
  if (!emptyEl) return;
4775
- const fileBtns = this._orderedFileNames().map(f => {
4776
- const ext = f.endsWith('.ts') ? 'ts' : f.endsWith('.js') ? 'js' : f.endsWith('.json') ? 'json' : f.endsWith('.md') ? 'md' : 'txt';
4777
- return `
4778
- <button type="button" class="codelab-empty-file-btn" data-cl-file="${escapeHtml(f)}" title="Open ${escapeHtml(f)}">
4779
- <span class="codelab-tab__ext codelab-tab__ext--${ext}">${ext.toUpperCase()}</span>
4780
- <span>${escapeHtml(f)}</span>
4781
- </button>
4782
- `;
4783
- }).join('');
4784
-
4785
4791
  emptyEl.innerHTML = `
4786
4792
  <div class="codelab-empty-editor__inner">
4787
- <div class="codelab-empty-editor__icon" aria-hidden="true">
4788
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
4789
- <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
4790
- <polyline points="14 2 14 8 20 8"/>
4791
- </svg>
4792
- </div>
4793
- <h2 class="codelab-empty-editor__title">No Open Editors</h2>
4794
- <p class="codelab-empty-editor__subtitle">Select a file from the explorer on the left or click a workspace file below to open.</p>
4795
- <div class="codelab-empty-editor__files" role="group" aria-label="Workspace Files">
4796
- ${fileBtns}
4797
- </div>
4798
- <div class="codelab-empty-editor__actions">
4799
- <button type="button" class="codelab-btn codelab-btn--run" data-cl-action="run-demo" title="Run demo.js (⇧⌘↵)">
4800
- ${CL_ICONS.play}
4801
- <span>Run Demo</span>
4802
- <span class="codelab-btn__kbd">⇧⌘↵</span>
4793
+ <div class="codelab-empty-editor__watermark" aria-hidden="true">code-lab</div>
4794
+ <div class="codelab-empty-editor__shortcuts" role="group" aria-label="Quick actions">
4795
+ <button type="button" class="codelab-empty-shortcut" data-cl-action="command-palette-files">
4796
+ <span>Go to File</span><kbd>⌘P</kbd>
4803
4797
  </button>
4804
- <button type="button" class="codelab-btn codelab-btn--test" data-cl-action="run-tests" title="Run Test Suite (⌘↵)">
4805
- ${CL_ICONS.check}
4806
- <span>Run Tests</span>
4807
- <span class="codelab-btn__kbd">⌘↵</span>
4798
+ <button type="button" class="codelab-empty-shortcut" data-cl-action="command-palette">
4799
+ <span>Show All Commands</span><kbd>⌘⇧P</kbd>
4808
4800
  </button>
4809
4801
  </div>
4802
+ <p class="codelab-empty-editor__subtitle">No editors open. Select a file from the Explorer to start editing.</p>
4810
4803
  </div>
4811
4804
  `;
4812
4805
  }
@@ -4876,7 +4869,7 @@ declare module 'bun:sqlite' {
4876
4869
  this.openCommandPalette('files');
4877
4870
  return;
4878
4871
  }
4879
- if ((e.metaKey || e.ctrlKey) && keyLower === 'c') {
4872
+ if (e.ctrlKey && !e.metaKey && keyLower === 'c') {
4880
4873
  const hasSelection = typeof window !== 'undefined' && window.getSelection && window.getSelection().toString().length > 0;
4881
4874
  if (!hasSelection && (this.isRunning || this._activeCommandAbortController)) {
4882
4875
  e.preventDefault();
@@ -5178,6 +5171,7 @@ declare module 'bun:sqlite' {
5178
5171
  if (action === 'run-demo') this.runDemo();
5179
5172
  else if (action === 'run-tests') this.runTests();
5180
5173
  else if (action === 'stop-run') this.stopExecution();
5174
+ else if (action === 'interrupt') this._handleInterrupt();
5181
5175
  else if (action === 'verify-step') this.verifyCurrentStep();
5182
5176
  else if (action === 'show-diff') this.showSolutionModal();
5183
5177
  else if (action === 'compare-diff') {
@@ -5771,6 +5765,48 @@ declare module 'bun:sqlite' {
5771
5765
  hSplitter.addEventListener('pointerup', onUp);
5772
5766
  });
5773
5767
  }
5768
+
5769
+ const fSplitter = this.container.querySelector('#cl-splitter-files');
5770
+ if (fSplitter) {
5771
+ const applyWidth = (w) => {
5772
+ this.explorerWidth = Math.round(w);
5773
+ shell.style.setProperty('--cl-explorer-width', `${this.explorerWidth}px`);
5774
+ if (this.editor && typeof this.editor.layout === 'function') this.editor.layout();
5775
+ };
5776
+
5777
+ fSplitter.addEventListener('dblclick', () => {
5778
+ applyWidth(196);
5779
+ this._saveState();
5780
+ });
5781
+
5782
+ fSplitter.addEventListener('pointerdown', e => {
5783
+ e.preventDefault();
5784
+ fSplitter.classList.add('is-dragging');
5785
+ shell.classList.add('is-resizing');
5786
+ try { fSplitter.setPointerCapture(e.pointerId); } catch (_) {}
5787
+
5788
+ const onMove = ev => {
5789
+ const ws = this.container.querySelector('.codelab-workspace');
5790
+ const rect = (ws || shell).getBoundingClientRect();
5791
+ const minW = 140;
5792
+ const maxW = Math.max(minW, Math.floor(rect.width * 0.5));
5793
+ const nextW = Math.min(maxW, Math.max(minW, Math.round(ev.clientX - rect.left)));
5794
+ applyWidth(nextW);
5795
+ };
5796
+
5797
+ const onUp = ev => {
5798
+ fSplitter.classList.remove('is-dragging');
5799
+ shell.classList.remove('is-resizing');
5800
+ try { fSplitter.releasePointerCapture(ev.pointerId); } catch (_) {}
5801
+ fSplitter.removeEventListener('pointermove', onMove);
5802
+ fSplitter.removeEventListener('pointerup', onUp);
5803
+ this._saveState();
5804
+ };
5805
+
5806
+ fSplitter.addEventListener('pointermove', onMove);
5807
+ fSplitter.addEventListener('pointerup', onUp);
5808
+ });
5809
+ }
5774
5810
  }
5775
5811
 
5776
5812
  selectStep(idx, shouldJump = true) {
@@ -6167,6 +6203,12 @@ declare module 'bun:sqlite' {
6167
6203
  }
6168
6204
 
6169
6205
  // ── Execution Engine (Web Worker + Virtual Node Runtime) ───────────────
6206
+ _isAbortResult(res, signal) {
6207
+ if (signal && signal.aborted) return true;
6208
+ if (!res || typeof res !== 'object') return false;
6209
+ return Boolean(res.cancelled || res.aborted || res.exitCode === 130);
6210
+ }
6211
+
6170
6212
  async _executeRuntime(execOptions) {
6171
6213
  const t0 = typeof performance !== 'undefined' ? performance.now() : Date.now();
6172
6214
  const payload = {
@@ -6203,7 +6245,11 @@ declare module 'bun:sqlite' {
6203
6245
  this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
6204
6246
  return res;
6205
6247
  } catch (err) {
6206
- this._setRuntimeStatus('error', 'Execution error');
6248
+ if (payload.signal && payload.signal.aborted) {
6249
+ this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
6250
+ } else {
6251
+ this._setRuntimeStatus('error', 'Execution error');
6252
+ }
6207
6253
  throw err;
6208
6254
  }
6209
6255
  }
@@ -6245,18 +6291,21 @@ declare module 'bun:sqlite' {
6245
6291
  }
6246
6292
  });
6247
6293
  this._flushTerminalStream();
6294
+ const aborted = this._isAbortResult(res, abortCtrl.signal);
6248
6295
 
6249
- if (!streamedStdout && res.stdout) {
6296
+ if (!aborted && !streamedStdout && res.stdout) {
6250
6297
  this.terminalLogs.push({ type: 'stdout', text: res.stdout.replace(/\n$/, '') });
6251
6298
  }
6252
- if (!streamedStderr && res.stderr) {
6299
+ if (!aborted && !streamedStderr && res.stderr) {
6253
6300
  this.terminalLogs.push({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
6254
6301
  }
6255
- if (res.error) {
6302
+ if (!aborted && res.error) {
6256
6303
  this.terminalLogs.push({ type: 'stderr', text: formatErrorText(res.error) });
6257
6304
  }
6258
- this.lastFsSnapshot = res.fsSnapshot || [];
6259
- this.lastHttpTrace = res.httpTrace || [];
6305
+ if (!aborted) {
6306
+ this.lastFsSnapshot = res.fsSnapshot || [];
6307
+ this.lastHttpTrace = res.httpTrace || [];
6308
+ }
6260
6309
 
6261
6310
  if (this.onRun) {
6262
6311
  try { this.onRun(res); } catch (_) {}
@@ -6264,7 +6313,9 @@ declare module 'bun:sqlite' {
6264
6313
  this._emitEvent('codelab:run', { labId: this.labId, mode: 'run', entry, result: res });
6265
6314
  } catch (err) {
6266
6315
  this._flushTerminalStream();
6267
- this.terminalLogs.push({ type: 'stderr', text: `Execution error: ${formatErrorText(err)}` });
6316
+ if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
6317
+ this.terminalLogs.push({ type: 'stderr', text: `Execution error: ${formatErrorText(err)}` });
6318
+ }
6268
6319
  } finally {
6269
6320
  if (this._activeCommandAbortController === abortCtrl) {
6270
6321
  this._activeCommandAbortController = null;
@@ -6313,18 +6364,21 @@ declare module 'bun:sqlite' {
6313
6364
  }
6314
6365
  });
6315
6366
  this._flushTerminalStream();
6367
+ const aborted = this._isAbortResult(res, abortCtrl.signal);
6316
6368
 
6317
- this.lastTestResults = res.testResults || [];
6318
- this.lastFsSnapshot = res.fsSnapshot || [];
6319
- this.lastHttpTrace = res.httpTrace || [];
6369
+ if (!aborted) {
6370
+ this.lastTestResults = res.testResults || [];
6371
+ this.lastFsSnapshot = res.fsSnapshot || [];
6372
+ this.lastHttpTrace = res.httpTrace || [];
6373
+ }
6320
6374
 
6321
- if (!streamedStdout && res.stdout) {
6375
+ if (!aborted && !streamedStdout && res.stdout) {
6322
6376
  this.terminalLogs.push({ type: 'stdout', text: res.stdout.replace(/\n$/, '') });
6323
6377
  }
6324
- if (!streamedStderr && res.stderr) {
6378
+ if (!aborted && !streamedStderr && res.stderr) {
6325
6379
  this.terminalLogs.push({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
6326
6380
  }
6327
- if (res.error) {
6381
+ if (!aborted && res.error) {
6328
6382
  this.terminalLogs.push({ type: 'stderr', text: formatErrorText(res.error) });
6329
6383
  }
6330
6384
 
@@ -6375,7 +6429,9 @@ declare module 'bun:sqlite' {
6375
6429
  }
6376
6430
  } catch (err) {
6377
6431
  this._flushTerminalStream();
6378
- this.terminalLogs.push({ type: 'stderr', text: `Test runner error: ${formatErrorText(err)}` });
6432
+ if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
6433
+ this.terminalLogs.push({ type: 'stderr', text: `Test runner error: ${formatErrorText(err)}` });
6434
+ }
6379
6435
  } finally {
6380
6436
  if (this._activeCommandAbortController === abortCtrl) {
6381
6437
  this._activeCommandAbortController = null;
@@ -6466,16 +6522,19 @@ declare module 'bun:sqlite' {
6466
6522
  onStderr: (c) => { streamedStderr = true; this._appendTerminalStream('stderr', c); }
6467
6523
  });
6468
6524
  this._flushTerminalStream();
6525
+ const aborted = this._isAbortResult(res, abortCtrl.signal);
6469
6526
  const cleanStdout = res.stdout ? res.stdout.replace(/\n$/, '') : '';
6470
- if (!streamedStdout && cleanStdout) this.terminalLogs.push({ type: 'stdout', text: cleanStdout });
6471
- if (!streamedStderr && res.stderr) this.terminalLogs.push({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
6472
- if (res.replValue !== undefined && cleanStdout !== String(res.replValue)) {
6527
+ if (!aborted && !streamedStdout && cleanStdout) this.terminalLogs.push({ type: 'stdout', text: cleanStdout });
6528
+ if (!aborted && !streamedStderr && res.stderr) this.terminalLogs.push({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
6529
+ if (!aborted && res.replValue !== undefined && cleanStdout !== String(res.replValue)) {
6473
6530
  this.terminalLogs.push({ type: 'success', text: `→ ${res.replValue}` });
6474
6531
  }
6475
- if (res.error) this.terminalLogs.push({ type: 'stderr', text: formatErrorText(res.error) });
6532
+ if (!aborted && res.error) this.terminalLogs.push({ type: 'stderr', text: formatErrorText(res.error) });
6476
6533
  } catch (err) {
6477
6534
  this._flushTerminalStream();
6478
- this.terminalLogs.push({ type: 'stderr', text: formatErrorText(err) });
6535
+ if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
6536
+ this.terminalLogs.push({ type: 'stderr', text: formatErrorText(err) });
6537
+ }
6479
6538
  } finally {
6480
6539
  if (this._activeCommandAbortController === abortCtrl) {
6481
6540
  this._activeCommandAbortController = null;
@@ -6534,6 +6593,7 @@ declare module 'bun:sqlite' {
6534
6593
  signal: abortCtrl.signal
6535
6594
  });
6536
6595
  this._flushTerminalStream();
6596
+ const aborted = this._isAbortResult(shellRes, abortCtrl.signal);
6537
6597
  this.cwd = this.shell.cwd || this.cwd;
6538
6598
  this._syncVfsSnapshot(null, true);
6539
6599
 
@@ -6553,10 +6613,10 @@ declare module 'bun:sqlite' {
6553
6613
 
6554
6614
  const isCmdNotFound = shellRes && shellRes.exitCode === 127 && typeof shellRes.stderr === 'string' && shellRes.stderr.includes('command not found');
6555
6615
  if (!isCmdNotFound) {
6556
- if (shellRes && shellRes.stdout && !streamedStdout) {
6616
+ if (!aborted && shellRes && shellRes.stdout && !streamedStdout) {
6557
6617
  this.terminalLogs.push({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
6558
6618
  }
6559
- if (shellRes && shellRes.stderr && !streamedStderr) {
6619
+ if (!aborted && shellRes && shellRes.stderr && !streamedStderr) {
6560
6620
  this.terminalLogs.push({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') });
6561
6621
  }
6562
6622
  this._renderDrawerBody();
@@ -6569,7 +6629,9 @@ declare module 'bun:sqlite' {
6569
6629
  }
6570
6630
  } catch (err) {
6571
6631
  this._flushTerminalStream();
6572
- this.terminalLogs.push({ type: 'stderr', text: formatErrorText(err) });
6632
+ if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
6633
+ this.terminalLogs.push({ type: 'stderr', text: formatErrorText(err) });
6634
+ }
6573
6635
  this._renderDrawerBody();
6574
6636
  return;
6575
6637
  } finally {
@@ -6605,17 +6667,18 @@ declare module 'bun:sqlite' {
6605
6667
  }
6606
6668
  });
6607
6669
  this._flushTerminalStream();
6670
+ const aborted = this._isAbortResult(res, fallbackAbortCtrl.signal);
6608
6671
  const cleanStdout = res.stdout ? res.stdout.replace(/\n$/, '') : '';
6609
- if (!streamedFallbackStdout && cleanStdout) {
6672
+ if (!aborted && !streamedFallbackStdout && cleanStdout) {
6610
6673
  this.terminalLogs.push({ type: 'stdout', text: cleanStdout });
6611
6674
  }
6612
- if (!streamedFallbackStderr && res.stderr) {
6675
+ if (!aborted && !streamedFallbackStderr && res.stderr) {
6613
6676
  this.terminalLogs.push({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
6614
6677
  }
6615
- if (res.replValue !== undefined && cleanStdout !== String(res.replValue)) {
6678
+ if (!aborted && res.replValue !== undefined && cleanStdout !== String(res.replValue)) {
6616
6679
  this.terminalLogs.push({ type: 'success', text: `→ ${res.replValue}` });
6617
6680
  }
6618
- if (res.error) {
6681
+ if (!aborted && res.error) {
6619
6682
  const errStr = formatErrorText(res.error);
6620
6683
  if (/^[a-zA-Z0-9_-]+$/.test(trimmed) && errStr.includes(`ReferenceError: ${trimmed} is not defined`)) {
6621
6684
  this.terminalLogs.push({ type: 'stderr', text: `codelab: ${trimmed}: command not found (type "help" for commands or enter a JS/TS expression)` });
@@ -6625,7 +6688,9 @@ declare module 'bun:sqlite' {
6625
6688
  }
6626
6689
  } catch (err) {
6627
6690
  this._flushTerminalStream();
6628
- this.terminalLogs.push({ type: 'stderr', text: formatErrorText(err) });
6691
+ if (!(fallbackAbortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
6692
+ this.terminalLogs.push({ type: 'stderr', text: formatErrorText(err) });
6693
+ }
6629
6694
  } finally {
6630
6695
  if (this._activeCommandAbortController === fallbackAbortCtrl) {
6631
6696
  this._activeCommandAbortController = null;
@@ -6877,8 +6942,13 @@ declare module 'bun:sqlite' {
6877
6942
  const intoRoot = options.intoRoot !== false;
6878
6943
  const targetDir = intoRoot ? '/workspace' : `/workspace/${parsed.repo}`;
6879
6944
  const cmdDisplay = `git clone ${repoInput}${intoRoot ? ' .' : ''}`;
6945
+ this.drawerTab = 'terminal';
6880
6946
  this.terminalLogs.push({ type: 'cmd', text: cmdDisplay });
6947
+ this.isRunning = true;
6948
+ const abortCtrl = new AbortController();
6949
+ this._activeCommandAbortController = abortCtrl;
6881
6950
  this._renderDrawerBody();
6951
+ this._updateRunStateUI();
6882
6952
 
6883
6953
  try {
6884
6954
  if (intoRoot && this.shell && this.shell.vfs) {
@@ -6901,6 +6971,7 @@ declare module 'bun:sqlite' {
6901
6971
  maxFiles: options.maxFiles || 250,
6902
6972
  maxFileSize: options.maxFileSize || 512 * 1024,
6903
6973
  fetchImpl: options.fetchImpl || (this.shell && this.shell.options ? this.shell.options.fetchImpl : undefined),
6974
+ signal: abortCtrl.signal,
6904
6975
  onProgress: options.onProgress
6905
6976
  });
6906
6977
 
@@ -6972,10 +7043,18 @@ declare module 'bun:sqlite' {
6972
7043
  this._emitEvent('repo:cloned', eventDetail);
6973
7044
  return result;
6974
7045
  } catch (err) {
6975
- const msg = err && err.message ? err.message : String(err);
6976
- this.terminalLogs.push({ type: 'stderr', text: msg });
7046
+ if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
7047
+ const msg = err && err.message ? err.message : String(err);
7048
+ this.terminalLogs.push({ type: 'stderr', text: msg });
7049
+ }
6977
7050
  this._renderDrawerBody();
6978
7051
  throw err;
7052
+ } finally {
7053
+ if (this._activeCommandAbortController === abortCtrl) {
7054
+ this._activeCommandAbortController = null;
7055
+ }
7056
+ this.isRunning = false;
7057
+ this._updateRunStateUI();
6979
7058
  }
6980
7059
  }
6981
7060