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