@innovatorved/code-lab 0.1.0 → 0.1.2

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.js CHANGED
@@ -1170,6 +1170,8 @@ declare module 'bun:sqlite' {
1170
1170
  this.completedSteps = new Set(this.savedState.completedSteps || []);
1171
1171
  this.folders = new Set(this.savedState?.folders || []);
1172
1172
  this.collapsedFolders = new Set(this.savedState?.collapsedFolders || []);
1173
+ this.explorerFolder = this.savedState?.explorerFolder || ''; // '' = workspace root, else folder path scope
1174
+ this.folderSwitcherOpen = false;
1173
1175
  this.creatingItem = null; // { type: 'file' | 'folder', parentFolder: string } | null
1174
1176
  this.renamingItem = null;
1175
1177
  this._draggedFile = null;
@@ -1505,7 +1507,8 @@ declare module 'bun:sqlite' {
1505
1507
  openTabs: Array.isArray(this.openTabs) ? [...this.openTabs] : undefined,
1506
1508
  activeFile: this.activeFile,
1507
1509
  folders: Array.from(this.folders || []),
1508
- collapsedFolders: Array.from(this.collapsedFolders || [])
1510
+ collapsedFolders: Array.from(this.collapsedFolders || []),
1511
+ explorerFolder: this.explorerFolder || ''
1509
1512
  };
1510
1513
  this.savedState = state;
1511
1514
  if (this.options && this.options.persistState === false) {
@@ -1949,23 +1952,59 @@ declare module 'bun:sqlite' {
1949
1952
  </button>
1950
1953
  ` : '';
1951
1954
 
1952
- let pathHtml = `<button type="button" class="codelab-breadcrumb__item codelab-breadcrumb__root" data-action="command-palette-files" data-cl-action="command-palette-files" title="Quick Open File (⌘P)">workspace</button>`;
1955
+ const folderOptions = this._listWorkspaceFolders();
1956
+ const scope = this.explorerFolder || '';
1957
+ const scopeLabel = scope ? scope.split('/').pop() : 'workspace';
1958
+
1959
+ const switcherHtml = `
1960
+ <div class="codelab-folder-switcher ${this.folderSwitcherOpen ? 'is-open' : ''}">
1961
+ <button type="button" class="codelab-folder-switcher__toggle ${scope ? 'is-scoped' : ''}" data-cl-action="toggle-folder-switcher" aria-haspopup="true" aria-expanded="${this.folderSwitcherOpen ? 'true' : 'false'}" title="Switch workspace folder">
1962
+ ${CL_ICONS.folder}
1963
+ <span class="codelab-folder-switcher__label">${escapeHtml(scopeLabel)}</span>
1964
+ ${CL_ICONS.chevronDown}
1965
+ </button>
1966
+ ${this.folderSwitcherOpen ? `
1967
+ <div class="codelab-folder-switcher__menu" role="menu" aria-label="Workspace folders">
1968
+ <div class="codelab-folder-switcher__section">Switch Folder</div>
1969
+ <button type="button" role="menuitem" class="codelab-folder-switcher__option ${!scope ? 'active' : ''}" data-cl-folder-option="">
1970
+ <span class="codelab-folder-switcher__icon">${CL_ICONS.folder}</span>
1971
+ <span class="codelab-folder-switcher__name">workspace</span>
1972
+ <span class="codelab-folder-switcher__path">/</span>
1973
+ </button>
1974
+ ${folderOptions.map(f => {
1975
+ const fDepth = f.split('/').length;
1976
+ const fName = f.split('/').pop();
1977
+ return `
1978
+ <button type="button" role="menuitem" class="codelab-folder-switcher__option ${scope === f ? 'active' : ''}" data-cl-folder-option="${escapeHtml(f)}" style="padding-left:${10 + (fDepth - 1) * 12}px;">
1979
+ <span class="codelab-folder-switcher__icon">${CL_ICONS.folder}</span>
1980
+ <span class="codelab-folder-switcher__name">${escapeHtml(fName)}</span>
1981
+ <span class="codelab-folder-switcher__path">${escapeHtml(f)}</span>
1982
+ </button>
1983
+ `;
1984
+ }).join('')}
1985
+ ${folderOptions.length ? '' : '<div class="codelab-folder-switcher__empty">No subfolders yet</div>'}
1986
+ </div>
1987
+ ` : ''}
1988
+ </div>
1989
+ `;
1990
+
1991
+ let pathHtml = `<button type="button" class="codelab-breadcrumbs__item codelab-breadcrumbs__item--root" data-action="command-palette-files" data-cl-action="command-palette-files" title="Quick Open File (⌘P)">workspace</button>`;
1953
1992
 
1954
1993
  if (this.activeFile) {
1955
1994
  const segments = this.activeFile.split('/');
1956
1995
  for (let i = 0; i < segments.length - 1; i++) {
1957
1996
  const folderPath = segments.slice(0, i + 1).join('/');
1958
- pathHtml += `<span class="codelab-breadcrumb__sep" aria-hidden="true">›</span>`;
1959
- pathHtml += `<button type="button" class="codelab-breadcrumb__item codelab-breadcrumb__folder" data-cl-breadcrumb-folder="${escapeHtml(folderPath)}" data-folder="${escapeHtml(folderPath)}">${escapeHtml(segments[i])}</button>`;
1997
+ pathHtml += `<span class="codelab-breadcrumbs__sep" aria-hidden="true">›</span>`;
1998
+ pathHtml += `<button type="button" class="codelab-breadcrumbs__item codelab-breadcrumbs__item--folder" data-cl-breadcrumb-folder="${escapeHtml(folderPath)}" data-folder="${escapeHtml(folderPath)}" title="Scope explorer to ${escapeHtml(folderPath)}">${escapeHtml(segments[i])}</button>`;
1960
1999
  }
1961
2000
  const fileName = segments[segments.length - 1];
1962
- pathHtml += `<span class="codelab-breadcrumb__sep" aria-hidden="true">›</span>`;
1963
- pathHtml += `<button type="button" class="codelab-breadcrumb__item codelab-breadcrumb__file active" data-cl-breadcrumb-file="${escapeHtml(this.activeFile)}" data-file="${escapeHtml(this.activeFile)}">${escapeHtml(fileName)}</button>`;
2001
+ pathHtml += `<span class="codelab-breadcrumbs__sep" aria-hidden="true">›</span>`;
2002
+ pathHtml += `<button type="button" class="codelab-breadcrumbs__item codelab-breadcrumbs__item--file active" data-cl-breadcrumb-file="${escapeHtml(this.activeFile)}" data-file="${escapeHtml(this.activeFile)}">${escapeHtml(fileName)}</button>`;
1964
2003
 
1965
2004
  const symbol = this._detectActiveSymbol(this.activeFile);
1966
2005
  if (symbol) {
1967
- pathHtml += `<span class="codelab-breadcrumb__sep" aria-hidden="true">›</span>`;
1968
- pathHtml += `<span class="codelab-breadcrumb__symbol" data-cl-breadcrumb-symbol="${escapeHtml(symbol)}">ƒ ${escapeHtml(symbol)}</span>`;
2006
+ pathHtml += `<span class="codelab-breadcrumbs__sep" aria-hidden="true">›</span>`;
2007
+ pathHtml += `<span class="codelab-breadcrumbs__item codelab-breadcrumbs__item--symbol" data-cl-breadcrumb-symbol="${escapeHtml(symbol)}">ƒ ${escapeHtml(symbol)}</span>`;
1969
2008
  }
1970
2009
  }
1971
2010
 
@@ -1986,7 +2025,10 @@ declare module 'bun:sqlite' {
1986
2025
 
1987
2026
  host.innerHTML = `
1988
2027
  ${expandBtnHtml}
1989
- <div class="codelab-breadcrumbs__path">${pathHtml}</div>
2028
+ <div class="codelab-breadcrumbs__left">
2029
+ ${switcherHtml}
2030
+ <div class="codelab-breadcrumbs__path">${pathHtml}</div>
2031
+ </div>
1990
2032
  <div class="codelab-breadcrumbs__actions">
1991
2033
  ${diffBtnHtml}
1992
2034
  <button type="button" class="codelab-breadcrumb__btn" data-action="command-palette" data-cl-action="command-palette" title="Open Command Palette (⌘⇧P)">
@@ -2229,6 +2271,36 @@ declare module 'bun:sqlite' {
2229
2271
  return rootNode;
2230
2272
  }
2231
2273
 
2274
+ _listWorkspaceFolders() {
2275
+ const set = new Set();
2276
+ if (this.folders) {
2277
+ for (const f of this.folders) {
2278
+ if (f) set.add(f);
2279
+ }
2280
+ }
2281
+ for (const filePath of this._orderedFileNames()) {
2282
+ const idx = filePath.lastIndexOf('/');
2283
+ if (idx <= 0) continue;
2284
+ const parts = filePath.slice(0, idx).split('/');
2285
+ let running = '';
2286
+ for (const p of parts) {
2287
+ running = running ? `${running}/${p}` : p;
2288
+ set.add(running);
2289
+ }
2290
+ }
2291
+ return Array.from(set).sort((a, b) => a.localeCompare(b));
2292
+ }
2293
+
2294
+ _resolveFolderNode(rootNode, folderPath) {
2295
+ if (!rootNode || !folderPath) return null;
2296
+ let current = rootNode;
2297
+ for (const seg of folderPath.split('/')) {
2298
+ if (!current || !current.folders || !current.folders.has(seg)) return null;
2299
+ current = current.folders.get(seg);
2300
+ }
2301
+ return current || null;
2302
+ }
2303
+
2232
2304
  _renderFileLists() {
2233
2305
  const explorerEl = this.container.querySelector('#cl-explorer-list');
2234
2306
  const tabsEl = this.container.querySelector('#cl-file-tabs');
@@ -2237,6 +2309,12 @@ declare module 'bun:sqlite' {
2237
2309
  if (!explorerEl || !tabsEl) return;
2238
2310
 
2239
2311
  const treeRoot = this._buildFileTree();
2312
+ if (this.explorerFolder && !this._resolveFolderNode(treeRoot, this.explorerFolder)) {
2313
+ this.explorerFolder = '';
2314
+ }
2315
+ const scope = this.explorerFolder || '';
2316
+ const renderRoot = scope ? this._resolveFolderNode(treeRoot, scope) : treeRoot;
2317
+ const rootParent = scope;
2240
2318
  let treeHtml = '';
2241
2319
 
2242
2320
  const renderNode = (node, depth) => {
@@ -2291,7 +2369,7 @@ declare module 'bun:sqlite' {
2291
2369
  }
2292
2370
  };
2293
2371
 
2294
- if (this.creatingItem && this.creatingItem.parentFolder === '') {
2372
+ if (this.creatingItem && this.creatingItem.parentFolder === rootParent) {
2295
2373
  treeHtml += `
2296
2374
  <div class="codelab-tree-create-row" style="padding-left: 10px;">
2297
2375
  <span class="codelab-tree-create-icon">${this.creatingItem.type === 'folder' ? CL_ICONS.folder : CL_ICONS.file}</span>
@@ -2300,7 +2378,16 @@ declare module 'bun:sqlite' {
2300
2378
  `;
2301
2379
  }
2302
2380
 
2303
- renderNode(treeRoot, 0);
2381
+ if (scope) {
2382
+ treeHtml += `
2383
+ <button type="button" class="codelab-scope-up" data-cl-folder-option="" title="Back to workspace root">
2384
+ <span class="codelab-scope-up__arrow">←</span>
2385
+ <span class="codelab-scope-up__label">workspace</span>
2386
+ </button>
2387
+ `;
2388
+ }
2389
+
2390
+ renderNode(renderRoot, 0);
2304
2391
  explorerEl.innerHTML = treeHtml;
2305
2392
 
2306
2393
  // Attach file drag events
@@ -3066,6 +3153,39 @@ declare module 'bun:sqlite' {
3066
3153
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
3067
3154
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
3068
3155
 
3156
+ // The workbench owns live terminal rendering. Only defer when an attached PTY
3157
+ // engine is itself rendering into the DOM (it is created with a null container in
3158
+ // production, so this remains the sole renderer there).
3159
+ const ptyOwnsDom = Boolean(this.ptyEngine && this.ptyEngine.container);
3160
+ const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
3161
+
3162
+ // Write a single logical line into the live terminal DOM immediately, so output
3163
+ // streams in as it is produced instead of appearing only when the command ends and
3164
+ // the whole drawer is re-rendered. Reuses the current partial-line element when it
3165
+ // is still attached (carriage-return overwrites / keep-alive updates).
3166
+ const patchLineInDom = (text) => {
3167
+ if (!canPatchDom) return;
3168
+ const html = ansiToHtml ? ansiToHtml(text) : escapeHtml(text);
3169
+ if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
3170
+ this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3171
+ this._activeStreamEl.innerHTML = html;
3172
+ } else {
3173
+ const newEl = document.createElement('div');
3174
+ newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3175
+ newEl.innerHTML = html;
3176
+ termLogEl.appendChild(newEl);
3177
+ this._activeStreamEl = newEl;
3178
+ }
3179
+ };
3180
+
3181
+ // A newline completes the current line: commit it to the log + DOM, then begin a fresh line.
3182
+ const commitActiveLine = () => {
3183
+ this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3184
+ patchLineInDom(this._activeStreamLine);
3185
+ this._activeStreamLine = '';
3186
+ this._activeStreamEl = null;
3187
+ };
3188
+
3069
3189
  let i = 0;
3070
3190
  while (i < rawText.length) {
3071
3191
  if (rawText.startsWith('\x1b[2K', i)) {
@@ -3100,20 +3220,22 @@ declare module 'bun:sqlite' {
3100
3220
  const ch = rawText[i];
3101
3221
  if (ch === '\r') {
3102
3222
  if (i + 1 < rawText.length && rawText[i + 1] === '\n') {
3103
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3104
- this._activeStreamLine = '';
3105
- this._activeStreamEl = null;
3223
+ commitActiveLine();
3106
3224
  i += 2;
3107
3225
  continue;
3108
3226
  } else {
3227
+ // Bare carriage return: flush the current text into the active line, then
3228
+ // keep overwriting that same DOM node (no extra line is appended).
3229
+ const rendered = this._activeStreamLine;
3230
+ if (rendered || this._activeStreamEl) {
3231
+ patchLineInDom(rendered);
3232
+ }
3109
3233
  this._activeStreamLine = '';
3110
3234
  i++;
3111
3235
  continue;
3112
3236
  }
3113
3237
  } else if (ch === '\n') {
3114
- this.terminalLogs.push({ type: this._activeStreamType || type, text: this._activeStreamLine });
3115
- this._activeStreamLine = '';
3116
- this._activeStreamEl = null;
3238
+ commitActiveLine();
3117
3239
  i++;
3118
3240
  continue;
3119
3241
  } else {
@@ -3122,20 +3244,9 @@ declare module 'bun:sqlite' {
3122
3244
  }
3123
3245
  }
3124
3246
 
3125
- if (termLogEl && typeof document !== 'undefined') {
3126
- if (this._activeStreamLine) {
3127
- const formattedHtml = ansiToHtml ? ansiToHtml(this._activeStreamLine) : escapeHtml(this._activeStreamLine);
3128
- if (this._activeStreamEl && this._activeStreamEl.parentNode === termLogEl) {
3129
- this._activeStreamEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3130
- this._activeStreamEl.innerHTML = formattedHtml;
3131
- } else {
3132
- const newEl = document.createElement('div');
3133
- newEl.className = 'codelab-log-line ' + escapeHtml(this._activeStreamType || type);
3134
- newEl.innerHTML = formattedHtml;
3135
- termLogEl.appendChild(newEl);
3136
- this._activeStreamEl = newEl;
3137
- }
3138
- }
3247
+ // Render the still-open partial line so incremental progress stays visible.
3248
+ if (this._activeStreamLine) {
3249
+ patchLineInDom(this._activeStreamLine);
3139
3250
  }
3140
3251
 
3141
3252
  if (termSurface) {
@@ -3861,6 +3972,29 @@ declare module 'bun:sqlite' {
3861
3972
  this._portToasts.delete(p);
3862
3973
  }
3863
3974
 
3975
+ _showToast(message, kind = 'info') {
3976
+ const toastHost = this.container ? this.container.querySelector('#cl-toast-container') : null;
3977
+ if (!toastHost || typeof document === 'undefined') return;
3978
+ const toast = document.createElement('div');
3979
+ toast.className = `codelab-toast codelab-toast--${kind === 'error' ? 'error' : 'info'}`;
3980
+ const icon = kind === 'error' ? (CL_ICONS.x || '⚠') : (CL_ICONS.externalLink || CL_ICONS.radio || '');
3981
+ toast.innerHTML = `
3982
+ <div class="codelab-toast__icon">${icon}</div>
3983
+ <div class="codelab-toast__body">
3984
+ <div class="codelab-toast__meta">${escapeHtml(message)}</div>
3985
+ </div>
3986
+ <button type="button" class="codelab-toast__close" aria-label="Dismiss notification">${CL_ICONS.x || '×'}</button>
3987
+ `;
3988
+ const closeBtn = toast.querySelector('.codelab-toast__close');
3989
+ const remove = () => {
3990
+ if (typeof toast.remove === 'function') toast.remove();
3991
+ else if (toast.parentNode) toast.parentNode.removeChild(toast);
3992
+ };
3993
+ if (closeBtn) closeBtn.addEventListener('click', remove);
3994
+ toastHost.appendChild(toast);
3995
+ setTimeout(remove, 5000);
3996
+ }
3997
+
3864
3998
  _registerPreviewServiceWorker() {
3865
3999
  if (typeof navigator === 'undefined' || !navigator.serviceWorker || typeof navigator.serviceWorker.register !== 'function') return;
3866
4000
  const url = (this.options && this.options.previewSwUrl) || 'preview-sw.js';
@@ -3951,9 +4085,53 @@ declare module 'bun:sqlite' {
3951
4085
  _previewGo(urlOrPath) {
3952
4086
  let url = String(urlOrPath || '').trim();
3953
4087
  if (!url) return Promise.resolve();
4088
+
4089
+ const loopbackPort = this.previewState.port || this._firstListeningPort() || 3000;
4090
+ const localHostRe = /^(localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(:\d+)?(\/.*)?$/i;
4091
+
4092
+ // Normalize the input into an absolute URL.
3954
4093
  if (!/^https?:\/\//i.test(url)) {
3955
- url = `http://127.0.0.1:${this.previewState.port || this._firstListeningPort() || 3000}${url.startsWith('/') ? '' : '/'}${url}`;
4094
+ if (localHostRe.test(url)) {
4095
+ url = `http://${url}`;
4096
+ } else if (/^[a-z0-9-]+(\.[a-z0-9-]+)+(:\d+)?([/?#].*)?$/i.test(url)) {
4097
+ // Bare public domain, e.g. "google.com" or "example.com/path".
4098
+ url = `https://${url}`;
4099
+ } else {
4100
+ url = `http://127.0.0.1:${loopbackPort}${url.startsWith('/') ? '' : '/'}${url}`;
4101
+ }
3956
4102
  }
4103
+
4104
+ // Public (non-loopback) URLs cannot be served by the virtual loopback Service
4105
+ // Worker, so open them in a real browser tab instead of the in-browser frame.
4106
+ let isExternal = false;
4107
+ try {
4108
+ const u = new URL(url);
4109
+ const host = (u.hostname || '').toLowerCase();
4110
+ isExternal = !(host === 'localhost' || host === '127.0.0.1' || host === '0.0.0.0' || host === '::1' || host === '[::1]');
4111
+ } catch (_) { isExternal = false; }
4112
+
4113
+ if (isExternal) {
4114
+ let opened = false;
4115
+ if (typeof window !== 'undefined' && typeof window.open === 'function') {
4116
+ try {
4117
+ const win = window.open(url, '_blank');
4118
+ if (win) {
4119
+ try { win.opener = null; } catch (_) {}
4120
+ opened = true;
4121
+ }
4122
+ } catch (_) { opened = false; }
4123
+ }
4124
+ if (typeof this._showToast === 'function') {
4125
+ this._showToast(
4126
+ opened ? `Opened ${url} in a new tab` : `Could not open ${url} — allow pop-ups and try again`,
4127
+ opened ? 'info' : 'error'
4128
+ );
4129
+ }
4130
+ const inputEl = this.container.querySelector('#cl-preview-url-input');
4131
+ if (inputEl) inputEl.value = this.previewState.url || inputEl.value;
4132
+ return Promise.resolve();
4133
+ }
4134
+
3957
4135
  let port = this.previewState.port;
3958
4136
  let path = '/';
3959
4137
  try {
@@ -4063,7 +4241,7 @@ declare module 'bun:sqlite' {
4063
4241
  <button type="button" class="codelab-preview-btn" data-cl-action="preview-reload" title="Reload">${CL_ICONS.refresh || '⟳'}</button>
4064
4242
  </div>
4065
4243
  <select class="codelab-preview-port-select" data-cl-action="preview-port-change" aria-label="Preview port">${portOptions}</select>
4066
- <input type="text" class="codelab-preview-url-input" id="cl-preview-url-input" value="${escapeHtml(this.previewState.url)}" placeholder="http://127.0.0.1:3000/" aria-label="Preview URL" />
4244
+ <input type="text" class="codelab-preview-url-input" id="cl-preview-url-input" value="${escapeHtml(this.previewState.url)}" placeholder="127.0.0.1:3000/ or https://example.com" aria-label="Preview URL" title="Localhost/virtual ports load in-frame; public URLs open in a new tab" />
4067
4245
  <div class="codelab-preview-modes">
4068
4246
  <button type="button" class="codelab-preview-btn ${this.previewState.frameMode === 'desktop' ? 'active' : ''}" data-cl-action="preview-mode" data-mode="desktop" title="Desktop">${CL_ICONS.monitor || '▭'}</button>
4069
4247
  <button type="button" class="codelab-preview-btn ${this.previewState.frameMode === 'tablet' ? 'active' : ''}" data-cl-action="preview-mode" data-mode="tablet" title="Tablet">${CL_ICONS.tablet || '▢'}</button>
@@ -4682,6 +4860,11 @@ declare module 'bun:sqlite' {
4682
4860
  this._previewGo(previewInput.value);
4683
4861
  return;
4684
4862
  }
4863
+ if (e.key === 'Escape' && this.folderSwitcherOpen) {
4864
+ this.folderSwitcherOpen = false;
4865
+ this._renderBreadcrumbs();
4866
+ return;
4867
+ }
4685
4868
  if (e.key === 'F1' || ((e.metaKey || e.ctrlKey) && e.shiftKey && keyLower === 'p')) {
4686
4869
  e.preventDefault();
4687
4870
  this.openCommandPalette('commands');
@@ -4882,12 +5065,39 @@ declare module 'bun:sqlite' {
4882
5065
  return;
4883
5066
  }
4884
5067
 
5068
+ const fsToggle = e.target.closest('[data-cl-action="toggle-folder-switcher"]');
5069
+ if (fsToggle) {
5070
+ e.stopPropagation();
5071
+ this.folderSwitcherOpen = !this.folderSwitcherOpen;
5072
+ this._renderBreadcrumbs();
5073
+ return;
5074
+ }
5075
+
5076
+ const fsOption = e.target.closest('[data-cl-folder-option]');
5077
+ if (fsOption) {
5078
+ e.stopPropagation();
5079
+ const scopeVal = fsOption.dataset.clFolderOption || '';
5080
+ this.explorerFolder = scopeVal;
5081
+ if (scopeVal) this.collapsedFolders.delete(scopeVal);
5082
+ this.folderSwitcherOpen = false;
5083
+ this._renderFileLists();
5084
+ this._renderBreadcrumbs();
5085
+ return;
5086
+ }
5087
+
5088
+ if (this.folderSwitcherOpen && !e.target.closest('.codelab-folder-switcher')) {
5089
+ this.folderSwitcherOpen = false;
5090
+ this._renderBreadcrumbs();
5091
+ }
5092
+
4885
5093
  const bcFolder = e.target.closest('[data-cl-breadcrumb-folder]');
4886
5094
  if (bcFolder) {
4887
5095
  const folder = bcFolder.dataset.clBreadcrumbFolder;
4888
5096
  if (folder) {
4889
5097
  this.collapsedFolders.delete(folder);
5098
+ this.explorerFolder = folder;
4890
5099
  this._renderFileLists();
5100
+ this._renderBreadcrumbs();
4891
5101
  }
4892
5102
  return;
4893
5103
  }
@@ -5022,10 +5232,10 @@ declare module 'bun:sqlite' {
5022
5232
  this.isCreatingFile = true;
5023
5233
  this._renderFileLists();
5024
5234
  } else if (action === 'new-file-root') {
5025
- this.creatingItem = { type: 'file', parentFolder: '' };
5235
+ this.creatingItem = { type: 'file', parentFolder: this.explorerFolder || '' };
5026
5236
  this._renderFileLists();
5027
5237
  } else if (action === 'new-folder-root') {
5028
- this.creatingItem = { type: 'folder', parentFolder: '' };
5238
+ this.creatingItem = { type: 'folder', parentFolder: this.explorerFolder || '' };
5029
5239
  this._renderFileLists();
5030
5240
  } else if (action === 'new-file-folder') {
5031
5241
  const folder = actionBtn.dataset.clFolder || '';