@innovatorved/code-lab 0.6.1 → 0.7.1

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 (131) hide show
  1. package/ARCHITECTURE.md +2 -2
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +38 -1
  4. package/dist/apps/web/src/index.d.ts +0 -9
  5. package/dist/code-lab-sql.esm.js +19 -19
  6. package/dist/code-lab-sql.umd.js +20 -20
  7. package/dist/code-lab.css +1 -1
  8. package/dist/code-lab.d.ts +19 -1
  9. package/dist/code-lab.esm.js +933 -1685
  10. package/dist/code-lab.js +932 -1684
  11. package/dist/extensions/cpp.esm.js +132 -8751
  12. package/dist/extensions/cpp.js +124 -8761
  13. package/dist/extensions/guided-lab.esm.js +33 -6827
  14. package/dist/extensions/guided-lab.js +33 -6845
  15. package/dist/extensions/javascript.esm.js +1 -36
  16. package/dist/extensions/javascript.js +1 -58
  17. package/dist/extensions/python.esm.js +79 -8109
  18. package/dist/extensions/python.js +79 -8127
  19. package/dist/extensions/typescript.esm.js +1 -55
  20. package/dist/extensions/typescript.js +1 -77
  21. package/dist/index.d.ts +1 -1
  22. package/dist/modular-kernel.d.ts +0 -4
  23. package/dist/preview-sw.js +1 -1
  24. package/dist/runtime.esm.js +79 -79
  25. package/dist/runtime.js +79 -79
  26. package/dist/schemas.d.ts +22 -1
  27. package/dist/schemas.esm.js +33 -6806
  28. package/dist/schemas.js +33 -6822
  29. package/dist/shell.esm.js +248 -242
  30. package/dist/shell.js +248 -242
  31. package/dist/terminal.esm.js +8 -6
  32. package/dist/terminal.js +6 -6
  33. package/dist/workbench/command-palette.d.ts +0 -4
  34. package/dist/workbench/index.d.ts +0 -20
  35. package/dist/workbench/intellisense.d.ts +1 -7
  36. package/package.json +3 -10
  37. package/src/code-lab.css +11 -503
  38. package/src/extensions/cpp.ts +11 -29
  39. package/src/extensions/guided-lab.ts +6 -2
  40. package/src/extensions/python.ts +9 -3
  41. package/src/index.ts +1 -1
  42. package/src/modular-kernel.ts +0 -4
  43. package/src/runtime.ts +153 -42
  44. package/src/schemas.ts +12 -3
  45. package/src/shell.ts +109 -16
  46. package/src/terminal.ts +4 -2
  47. package/src/workbench/command-palette.ts +22 -302
  48. package/src/workbench/diff-editor.ts +2 -0
  49. package/src/workbench/icons.ts +1 -1
  50. package/src/workbench/index.ts +0 -15
  51. package/src/workbench/intellisense.ts +17 -4
  52. package/src/workbench.ts +432 -456
  53. package/dist/code-lab.umd.js +0 -6109
  54. package/dist/packages/editor/src/index.d.ts +0 -118
  55. package/dist/packages/preview/src/index.d.ts +0 -34
  56. package/dist/packages/runtime/src/index.d.ts +0 -47
  57. package/dist/packages/terminal/src/index.d.ts +0 -54
  58. package/dist/workbench/drawer.d.ts +0 -18
  59. package/dist/workbench/file-tree.d.ts +0 -11
  60. package/dist/workbench/guided-pane.d.ts +0 -11
  61. package/dist/workbench/styles.d.ts +0 -4
  62. package/dist/workbench/toolbar.d.ts +0 -17
  63. package/packages/commands/README.md +0 -7
  64. package/packages/commands/package.json +0 -16
  65. package/packages/commands/src/index.ts +0 -467
  66. package/packages/commands/tsconfig.json +0 -22
  67. package/packages/core/README.md +0 -12
  68. package/packages/core/package.json +0 -13
  69. package/packages/core/src/di.ts +0 -147
  70. package/packages/core/src/disposable.ts +0 -112
  71. package/packages/core/src/errors.ts +0 -205
  72. package/packages/core/src/events.ts +0 -157
  73. package/packages/core/src/index.ts +0 -49
  74. package/packages/core/src/path.ts +0 -118
  75. package/packages/core/src/registry.ts +0 -61
  76. package/packages/core/tsconfig.json +0 -19
  77. package/packages/editor/README.md +0 -9
  78. package/packages/editor/package.json +0 -18
  79. package/packages/editor/src/index.ts +0 -344
  80. package/packages/editor/tsconfig.json +0 -24
  81. package/packages/fs/README.md +0 -7
  82. package/packages/fs/package.json +0 -16
  83. package/packages/fs/src/backends.ts +0 -301
  84. package/packages/fs/src/index.ts +0 -18
  85. package/packages/fs/src/types.ts +0 -44
  86. package/packages/fs/src/vfs-service.ts +0 -257
  87. package/packages/fs/tsconfig.json +0 -22
  88. package/packages/preview/README.md +0 -3
  89. package/packages/preview/package.json +0 -16
  90. package/packages/preview/src/index.ts +0 -125
  91. package/packages/preview/tsconfig.json +0 -22
  92. package/packages/runtime/README.md +0 -3
  93. package/packages/runtime/package.json +0 -17
  94. package/packages/runtime/src/index.ts +0 -134
  95. package/packages/runtime/tsconfig.json +0 -23
  96. package/packages/settings/README.md +0 -7
  97. package/packages/settings/package.json +0 -16
  98. package/packages/settings/src/builtin-schemas.ts +0 -246
  99. package/packages/settings/src/configuration-service.ts +0 -609
  100. package/packages/settings/src/index.ts +0 -38
  101. package/packages/settings/src/jsonc.ts +0 -189
  102. package/packages/settings/src/schema.ts +0 -164
  103. package/packages/settings/tsconfig.json +0 -22
  104. package/packages/sql/README.md +0 -12
  105. package/packages/sql/package.json +0 -13
  106. package/packages/sql/src/completions.ts +0 -359
  107. package/packages/sql/src/diagnostics.ts +0 -200
  108. package/packages/sql/src/formatter.ts +0 -271
  109. package/packages/sql/src/index.ts +0 -54
  110. package/packages/sql/src/sql-editor.ts +0 -802
  111. package/packages/sql/src/styles.ts +0 -524
  112. package/packages/sql/src/tokenizer.ts +0 -457
  113. package/packages/sql/src/types.ts +0 -148
  114. package/packages/sql/tsconfig.json +0 -19
  115. package/packages/terminal/README.md +0 -3
  116. package/packages/terminal/package.json +0 -16
  117. package/packages/terminal/src/index.ts +0 -183
  118. package/packages/terminal/tsconfig.json +0 -22
  119. package/packages/ui/README.md +0 -8
  120. package/packages/ui/package.json +0 -18
  121. package/packages/ui/src/index.ts +0 -40
  122. package/packages/ui/src/observability.ts +0 -173
  123. package/packages/ui/src/plugin-registry.ts +0 -289
  124. package/packages/ui/src/settings-dialog.ts +0 -911
  125. package/packages/ui/src/themes.ts +0 -333
  126. package/packages/ui/tsconfig.json +0 -24
  127. package/src/workbench/drawer.ts +0 -157
  128. package/src/workbench/file-tree.ts +0 -51
  129. package/src/workbench/guided-pane.ts +0 -43
  130. package/src/workbench/styles.ts +0 -211
  131. package/src/workbench/toolbar.ts +0 -182
package/src/workbench.ts CHANGED
@@ -83,333 +83,9 @@
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.1';
86
+ const CODELAB_VERSION = '0.7.1';
87
87
 
88
88
  // Ambient TypeScript declarations for Node.js built-ins inside Monaco
89
- const NODE_AMBIENT_DTS = `
90
- declare var require: (id: string) => any;
91
- declare var module: { exports: any };
92
- declare var exports: any;
93
- declare var __dirname: string;
94
- declare var __filename: string;
95
- declare var process: {
96
- env: Record<string, string | undefined>;
97
- argv: string[];
98
- version: string;
99
- versions: Record<string, string>;
100
- platform: string;
101
- arch: string;
102
- pid: number;
103
- cwd(): string;
104
- hrtime: { (time?: [number, number]): [number, number]; bigint(): bigint };
105
- nextTick(cb: (...args: any[]) => void, ...args: any[]): void;
106
- stdout: { write(chunk: any): boolean };
107
- stderr: { write(chunk: any): boolean };
108
- };
109
- declare class Buffer extends Uint8Array {
110
- static from(data: any, encoding?: string): Buffer;
111
- static alloc(size: number, fill?: any, encoding?: string): Buffer;
112
- static allocUnsafe(size: number): Buffer;
113
- static concat(list: Uint8Array[], totalLength?: number): Buffer;
114
- static isBuffer(obj: any): obj is Buffer;
115
- static byteLength(str: string | Uint8Array, encoding?: string): number;
116
- static compare(a: Uint8Array, b: Uint8Array): number;
117
- toString(encoding?: string, start?: number, end?: number): string;
118
- write(str: string, offset?: number, length?: number, encoding?: string): number;
119
- slice(start?: number, end?: number): Buffer;
120
- subarray(start?: number, end?: number): Buffer;
121
- equals(other: Uint8Array): boolean;
122
- copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
123
- readUInt8(offset?: number): number;
124
- readUInt16BE(offset?: number): number;
125
- readUInt16LE(offset?: number): number;
126
- readUInt32BE(offset?: number): number;
127
- readUInt32LE(offset?: number): number;
128
- readInt32BE(offset?: number): number;
129
- readInt32LE(offset?: number): number;
130
- readBigUInt64BE(offset?: number): bigint;
131
- readBigInt64BE(offset?: number): bigint;
132
- writeUInt8(value: number, offset?: number): number;
133
- writeUInt16BE(value: number, offset?: number): number;
134
- writeUInt16LE(value: number, offset?: number): number;
135
- writeUInt32BE(value: number, offset?: number): number;
136
- writeUInt32LE(value: number, offset?: number): number;
137
- writeInt32BE(value: number, offset?: number): number;
138
- writeInt32LE(value: number, offset?: number): number;
139
- writeBigUInt64BE(value: bigint, offset?: number): number;
140
- writeBigInt64BE(value: bigint, offset?: number): number;
141
- }
142
- declare module 'node:test' {
143
- export function describe(name: string, fn: () => any): void;
144
- export function it(name: string, fn: () => any): void;
145
- export function test(name: string, fn: () => any): void;
146
- export function before(fn: () => any): void;
147
- export function after(fn: () => any): void;
148
- export function beforeEach(fn: () => any): void;
149
- export function afterEach(fn: () => any): void;
150
- }
151
- declare module 'test' { export * from 'node:test'; }
152
- declare module 'node:assert' {
153
- function assert(value: any, message?: string | Error): void;
154
- namespace assert {
155
- function ok(value: any, message?: string | Error): void;
156
- function equal(actual: any, expected: any, message?: string | Error): void;
157
- function strictEqual(actual: any, expected: any, message?: string | Error): void;
158
- function notEqual(actual: any, expected: any, message?: string | Error): void;
159
- function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
160
- function deepEqual(actual: any, expected: any, message?: string | Error): void;
161
- function deepStrictEqual(actual: any, expected: any, message?: string | Error): void;
162
- function throws(block: () => any, error?: any, message?: string): void;
163
- function doesNotThrow(block: () => any, error?: any, message?: string): void;
164
- function rejects(block: (() => Promise<any>) | Promise<any>, error?: any, message?: string): Promise<void>;
165
- function doesNotReject(block: (() => Promise<any>) | Promise<any>, error?: any, message?: string): Promise<void>;
166
- function match(string: string, regexp: RegExp, message?: string): void;
167
- function doesNotMatch(string: string, regexp: RegExp, message?: string): void;
168
- function fail(message?: string | Error): never;
169
- }
170
- export = assert;
171
- }
172
- declare module 'assert' { import assert = require('node:assert'); export = assert; }
173
- declare module 'node:assert/strict' { import assert = require('node:assert'); export = assert; }
174
- declare module 'assert/strict' { import assert = require('node:assert'); export = assert; }
175
- declare module 'node:events' {
176
- export class EventEmitter {
177
- on(event: string | symbol, listener: (...args: any[]) => void): this;
178
- once(event: string | symbol, listener: (...args: any[]) => void): this;
179
- off(event: string | symbol, listener: (...args: any[]) => void): this;
180
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
181
- removeAllListeners(event?: string | symbol): this;
182
- emit(event: string | symbol, ...args: any[]): boolean;
183
- listenerCount(event: string | symbol): number;
184
- listeners(event: string | symbol): Function[];
185
- }
186
- export default EventEmitter;
187
- }
188
- declare module 'events' { export * from 'node:events'; }
189
- declare module 'node:crypto' {
190
- export function createHash(algorithm: 'md5' | 'sha1' | 'sha256' | 'sha512' | string): {
191
- update(data: string | Uint8Array): any;
192
- digest(encoding?: 'hex' | 'base64' | 'base64url'): any;
193
- };
194
- export function createHmac(algorithm: string, key: string | Uint8Array): {
195
- update(data: string | Uint8Array): any;
196
- digest(encoding?: 'hex' | 'base64' | 'base64url'): any;
197
- };
198
- export function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
199
- export function randomUUID(): string;
200
- export function randomBytes(size: number): Buffer;
201
- export function randomInt(min: number, max?: number): number;
202
- export function pbkdf2Sync(password: any, salt: any, iterations: number, keylen: number, digest: string): Buffer;
203
- export function scryptSync(password: any, salt: any, keylen: number, options?: any): Buffer;
204
- export function createCipheriv(algorithm: string, key: any, iv: any): any;
205
- export function createDecipheriv(algorithm: string, key: any, iv: any): any;
206
- }
207
- declare module 'crypto' { export * from 'node:crypto'; }
208
- declare module 'node:fs' {
209
- export function openSync(path: string, flags?: string): number;
210
- export function closeSync(fd: number): void;
211
- export function writeSync(fd: number, buffer: Uint8Array | string, offset?: number, length?: number, position?: number | null): number;
212
- export function readSync(fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null): number;
213
- export function fsyncSync(fd: number): void;
214
- export function fstatSync(fd: number): { size: number; isDirectory(): boolean; isFile(): boolean };
215
- export function statSync(path: string): { size: number; isDirectory(): boolean; isFile(): boolean };
216
- export function existsSync(path: string): boolean;
217
- export function mkdirSync(path: string, options?: any): void;
218
- export function mkdtempSync(prefix: string): string;
219
- export function readdirSync(path: string): string[];
220
- export function readFileSync(path: string, options?: any): any;
221
- export function writeFileSync(path: string, data: any, options?: any): void;
222
- export function appendFileSync(path: string, data: any, options?: any): void;
223
- export function copyFileSync(src: string, dest: string): void;
224
- export function truncateSync(path: string, len?: number): void;
225
- export function renameSync(oldPath: string, newPath: string): void;
226
- export function unlinkSync(path: string): void;
227
- export function rmSync(path: string, options?: any): void;
228
- export const promises: typeof import('node:fs/promises');
229
- }
230
- declare module 'fs' { export * from 'node:fs'; }
231
- declare module 'node:fs/promises' {
232
- export function readFile(path: string, options?: any): Promise<any>;
233
- export function writeFile(path: string, data: any, options?: any): Promise<void>;
234
- export function appendFile(path: string, data: any, options?: any): Promise<void>;
235
- export function mkdir(path: string, options?: any): Promise<void>;
236
- export function readdir(path: string): Promise<string[]>;
237
- export function stat(path: string): Promise<{ size: number; isDirectory(): boolean; isFile(): boolean }>;
238
- export function unlink(path: string): Promise<void>;
239
- export function rm(path: string, options?: any): Promise<void>;
240
- export function rename(oldPath: string, newPath: string): Promise<void>;
241
- }
242
- declare module 'fs/promises' { export * from 'node:fs/promises'; }
243
- declare module 'node:path' {
244
- export function join(...paths: string[]): string;
245
- export function resolve(...paths: string[]): string;
246
- export function normalize(p: string): string;
247
- export function relative(from: string, to: string): string;
248
- export function isAbsolute(p: string): boolean;
249
- export function dirname(p: string): string;
250
- export function basename(p: string, ext?: string): string;
251
- export function extname(p: string): string;
252
- export function parse(p: string): { root: string; dir: string; base: string; ext: string; name: string };
253
- export function format(pObj: any): string;
254
- export const sep: string;
255
- export const delimiter: string;
256
- }
257
- declare module 'path' { export * from 'node:path'; }
258
- declare module 'node:os' {
259
- export function tmpdir(): string;
260
- export function homedir(): string;
261
- export function hostname(): string;
262
- export function platform(): string;
263
- export function arch(): string;
264
- export function cpus(): any[];
265
- export const EOL: string;
266
- }
267
- declare module 'os' { export * from 'node:os'; }
268
- declare module 'node:zlib' {
269
- export function crc32(data: string | Uint8Array, value?: number): number;
270
- export function gzipSync(buf: string | Uint8Array): Buffer;
271
- export function gunzipSync(buf: Uint8Array): Buffer;
272
- export function deflateSync(buf: string | Uint8Array): Buffer;
273
- export function inflateSync(buf: Uint8Array): Buffer;
274
- }
275
- declare module 'zlib' { export * from 'node:zlib'; }
276
- declare module 'node:http' {
277
- export class Agent { constructor(opts?: any); destroy(): void; }
278
- export function createServer(handler: (req: any, res: any) => void): any;
279
- export function request(options: any, callback?: (res: any) => void): any;
280
- export function get(options: any, callback?: (res: any) => void): any;
281
- }
282
- declare module 'http' { export * from 'node:http'; }
283
- declare module 'node:https' { export * from 'node:http'; }
284
- declare module 'https' { export * from 'node:http'; }
285
- declare module 'node:net' {
286
- export class Socket { constructor(opts?: any); connect(...args: any[]): this; write(data: any): boolean; end(data?: any): this; destroy(): this; on(ev: string, cb: (...args: any[]) => void): this; }
287
- export class Server { listen(...args: any[]): this; close(cb?: () => void): this; on(ev: string, cb: (...args: any[]) => void): this; address(): any; }
288
- export function createServer(fn?: (socket: Socket) => void): Server;
289
- export function createConnection(...args: any[]): Socket;
290
- }
291
- declare module 'net' { export * from 'node:net'; }
292
- declare module 'node:stream' {
293
- import { EventEmitter } from 'node:events';
294
- export class Stream extends EventEmitter { pipe<T>(dest: T): T; }
295
- export class Readable extends Stream { constructor(opts?: any); push(chunk: any): boolean; read(size?: number): any; }
296
- export class Writable extends Stream { constructor(opts?: any); write(chunk: any, cb?: any): boolean; end(chunk?: any, cb?: any): this; }
297
- export class Duplex extends Readable { write(chunk: any, cb?: any): boolean; end(chunk?: any, cb?: any): this; }
298
- export class Transform extends Duplex {}
299
- export class PassThrough extends Transform {}
300
- export function pipeline(...streams: any[]): any;
301
- }
302
- declare module 'stream' { export * from 'node:stream'; }
303
- declare module 'node:util' {
304
- export function format(fmt: any, ...args: any[]): string;
305
- export function inspect(obj: any, opts?: any): string;
306
- export function promisify(fn: Function): (...args: any[]) => Promise<any>;
307
- export function callbackify(fn: Function): (...args: any[]) => void;
308
- export function inherits(ctor: any, superCtor: any): void;
309
- export const types: Record<string, (val: any) => boolean>;
310
- export class TextEncoder { encode(input?: string): Uint8Array; }
311
- export class TextDecoder { decode(input?: Uint8Array): string; }
312
- }
313
- declare module 'util' { export * from 'node:util'; }
314
- declare module 'node:url' {
315
- export { URL, URLSearchParams };
316
- export function parse(urlStr: string, parseQueryString?: boolean): any;
317
- export function format(urlObj: any): string;
318
- }
319
- declare module 'url' { export * from 'node:url'; }
320
- declare module 'node:querystring' {
321
- export function parse(str: string): Record<string, any>;
322
- export function stringify(obj: Record<string, any>): string;
323
- }
324
- declare module 'querystring' { export * from 'node:querystring'; }
325
- declare module 'node:perf_hooks' {
326
- export const performance: { now(): number; timeOrigin: number; mark(name: string): void; measure(name: string, start?: string, end?: string): void };
327
- }
328
- declare module 'perf_hooks' { export * from 'node:perf_hooks'; }
329
- declare module 'node:timers' {
330
- export { setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate };
331
- }
332
- declare module 'timers' { export * from 'node:timers'; }
333
- declare module 'node:timers/promises' {
334
- export function setTimeout<T = void>(delay?: number, value?: T): Promise<T>;
335
- export function setImmediate<T = void>(value?: T): Promise<T>;
336
- }
337
- declare module 'timers/promises' { export * from 'node:timers/promises'; }
338
- declare module 'node:string_decoder' {
339
- export class StringDecoder { constructor(encoding?: string); write(buf: Uint8Array): string; end(buf?: Uint8Array): string; }
340
- }
341
- declare module 'string_decoder' { export * from 'node:string_decoder'; }
342
- declare module 'node:dns' {
343
- export function lookup(hostname: string, cb: (err: any, address: string, family: number) => void): void;
344
- export function resolve(hostname: string, cb: (err: any, records: string[]) => void): void;
345
- }
346
- declare module 'dns' { export * from 'node:dns'; }
347
- declare module 'node:child_process' {
348
- export function execSync(cmd: string, opts?: any): Buffer | string;
349
- export function spawn(cmd: string, args?: string[], opts?: any): any;
350
- }
351
- declare module 'child_process' { export * from 'node:child_process'; }
352
- declare module 'node:buffer' { export { Buffer }; }
353
- declare module 'buffer' { export { Buffer }; }
354
- declare const Bun: {
355
- version: string;
356
- revision: string;
357
- env: Record<string, string | undefined>;
358
- serve(options: { port?: number; hostname?: string; fetch(req: Request, server?: any): Response | Promise<Response>; error?(err: Error): Response | Promise<Response> }): { port: number; hostname: string; url: string; stop(closeActiveConnections?: boolean): void };
359
- file(path: string, options?: { type?: string }): { size: number; type: string; text(): Promise<string>; json(): Promise<any>; arrayBuffer(): Promise<ArrayBuffer>; bytes(): Promise<Uint8Array>; exists(): Promise<boolean> };
360
- write(dest: string | any, input: string | Uint8Array | ArrayBuffer | Response | any): Promise<number>;
361
- sleep(ms: number): Promise<void>;
362
- sleepSync(ms: number): void;
363
- hash(input: string | Uint8Array, seed?: number): number;
364
- deepEquals(a: any, b: any, strict?: boolean): boolean;
365
- inspect(val: any): string;
366
- nanoseconds(): number;
367
- which(bin: string): string | null;
368
- escapeHTML(str: string): string;
369
- stringWidth(str: string): number;
370
- };
371
- declare module 'bun' {
372
- export const version: string;
373
- export const env: Record<string, string | undefined>;
374
- export const serve: typeof Bun.serve;
375
- export const file: typeof Bun.file;
376
- export const write: typeof Bun.write;
377
- export const sleep: typeof Bun.sleep;
378
- export const sleepSync: typeof Bun.sleepSync;
379
- export const hash: typeof Bun.hash;
380
- export const deepEquals: typeof Bun.deepEquals;
381
- export const inspect: typeof Bun.inspect;
382
- export const nanoseconds: typeof Bun.nanoseconds;
383
- export const which: typeof Bun.which;
384
- export const escapeHTML: typeof Bun.escapeHTML;
385
- export const stringWidth: typeof Bun.stringWidth;
386
- export default Bun;
387
- }
388
- declare module 'bun:test' {
389
- export function test(name: string, fn: () => any, timeout?: number): Promise<void>;
390
- export function it(name: string, fn: () => any, timeout?: number): Promise<void>;
391
- export function describe(name: string, fn: () => void): void;
392
- export function beforeAll(fn: () => any): void;
393
- export function afterAll(fn: () => any): void;
394
- export function beforeEach(fn: () => any): void;
395
- export function afterEach(fn: () => any): void;
396
- export function expect(actual: any): any;
397
- export const mock: any;
398
- export const jest: any;
399
- }
400
- declare module 'bun:sqlite' {
401
- export class Database {
402
- constructor(filename?: string, options?: any);
403
- exec(sql: string): this;
404
- run(sql: string, ...params: any[]): { changes: number; lastInsertRowid: number };
405
- query(sql: string): { all(...params: any[]): any[]; get(...params: any[]): any; values(...params: any[]): any[][]; run(...params: any[]): { changes: number; lastInsertRowid: number } };
406
- prepare(sql: string): { all(...params: any[]): any[]; get(...params: any[]): any; values(...params: any[]): any[][]; run(...params: any[]): { changes: number; lastInsertRowid: number }; finalize(): void };
407
- transaction<T extends (...args: any[]) => any>(fn: T): T;
408
- close(): void;
409
- }
410
- export default Database;
411
- }
412
- `;
413
89
 
414
90
  const _sharedHtmlMod = (typeof CodeLabHtml !== 'undefined' && CodeLabHtml) ||
415
91
  (root && root.CodeLabHtml) ||
@@ -1113,8 +789,6 @@ declare module 'bun:sqlite' {
1113
789
  if (typeof jsDefaults.setEagerModelSync === 'function') jsDefaults.setEagerModelSync(true);
1114
790
  tsDefaults.setDiagnosticsOptions({ noSemanticValidation: false, noSyntaxValidation: false });
1115
791
  jsDefaults.setDiagnosticsOptions({ noSemanticValidation: false, noSyntaxValidation: false });
1116
- tsDefaults.addExtraLib(NODE_AMBIENT_DTS, 'file:///node-ambient.d.ts');
1117
- jsDefaults.addExtraLib(NODE_AMBIENT_DTS, 'file:///node-ambient.d.ts');
1118
792
  }
1119
793
 
1120
794
  resolve(m);
@@ -2107,10 +1781,20 @@ int main() {
2107
1781
  }
2108
1782
 
2109
1783
  // Load persisted user settings from localStorage if available
1784
+ const persistedUserKeys = new Set();
2110
1785
  if (this.persistState && this.configuration) {
2111
1786
  const savedUserSettings = safeStorageGet(`${STORAGE_PREFIX}user-settings`, this.logger);
2112
1787
  if (savedUserSettings) {
2113
1788
  this.configuration.importProfile(savedUserSettings);
1789
+ try {
1790
+ const parsedSaved = JSON.parse(savedUserSettings);
1791
+ const savedObj = parsedSaved && typeof parsedSaved.user === 'object' ? parsedSaved.user : parsedSaved;
1792
+ if (savedObj && typeof savedObj === 'object') {
1793
+ for (const k of Object.keys(savedObj)) persistedUserKeys.add(k);
1794
+ }
1795
+ } catch (_err) {
1796
+ void _err;
1797
+ }
2114
1798
  }
2115
1799
  }
2116
1800
 
@@ -2127,9 +1811,35 @@ int main() {
2127
1811
  }
2128
1812
  }
2129
1813
 
2130
- // Apply constructor overrides onto Layer 4 if passed in options.settings
2131
- if (this.options && this.options.settings && typeof this.options.settings === 'object' && this.configuration) {
2132
- this.configuration.setOverrides(this.options.settings);
1814
+ // Apply host-provided initial settings/config cleanly:
1815
+ // - `options.userSettings` / `options.defaultSettings` (and `options.settings` / `options.config`
1816
+ // when `options.lockSettings !== true`) seed Layer 2 user settings so host apps can customize
1817
+ // defaults while end-users can still adjust them in the Settings UI.
1818
+ // - `options.overrides` (or `options.settings` with `options.lockSettings === true`) lock Layer 4.
1819
+ if (this.options && this.configuration) {
1820
+ const seedSources = [
1821
+ this.options.defaultSettings,
1822
+ this.options.userSettings,
1823
+ this.options.config,
1824
+ this.options.lockSettings === true ? null : this.options.settings
1825
+ ];
1826
+ for (const src of seedSources) {
1827
+ if (!src || typeof src !== 'object') continue;
1828
+ for (const [k, v] of Object.entries(src)) {
1829
+ if (!this.persistState || !persistedUserKeys.has(k)) {
1830
+ this.configuration.setUserSetting(k, v);
1831
+ }
1832
+ }
1833
+ }
1834
+ const lockedOverrides = {
1835
+ ...(this.options.lockSettings === true && this.options.settings && typeof this.options.settings === 'object'
1836
+ ? this.options.settings
1837
+ : {}),
1838
+ ...(this.options.overrides && typeof this.options.overrides === 'object' ? this.options.overrides : {})
1839
+ };
1840
+ if (Object.keys(lockedOverrides).length > 0) {
1841
+ this.configuration.setOverrides(lockedOverrides);
1842
+ }
2133
1843
  }
2134
1844
 
2135
1845
  // Register built-in commands & keybindings
@@ -3523,38 +3233,35 @@ int main() {
3523
3233
  }
3524
3234
  }
3525
3235
  }
3526
- if (targetFile && this.files[targetFile] !== undefined) {
3527
- this._syncDotCodelabConfig();
3528
- this._vfsWriteFile(targetFile, this.files[targetFile]);
3529
- } else {
3530
- this._syncFilesToShellVfs();
3531
- }
3532
- if (!this._savedSnapshot) this._savedSnapshot = {};
3533
- const autoSaveMode = this.configuration
3534
- ? this.configuration.get('files.autoSave', 'afterDelay')
3535
- : 'afterDelay';
3536
- if (saveAll || !targetFile || (autoSaveMode !== 'off' && autoSaveMode !== 'onFocusChange')) {
3537
- this._savedSnapshot = { ...(this.files || {}) };
3538
- this._clearFileDirty();
3539
- this._saveState({ flushFiles: true });
3540
- } else {
3541
- if (this.files[targetFile] !== undefined) {
3542
- this._savedSnapshot[targetFile] = this.files[targetFile];
3236
+ const finalizeSave = () => {
3237
+ if (targetFile && this.files[targetFile] !== undefined) {
3238
+ this._syncDotCodelabConfig();
3239
+ this._vfsWriteFile(targetFile, this.files[targetFile]);
3543
3240
  } else {
3544
- delete this._savedSnapshot[targetFile];
3241
+ this._syncFilesToShellVfs();
3545
3242
  }
3546
- this._clearFileDirty(targetFile);
3547
- this._saveState({ flushSnapshotOnly: true });
3548
- }
3549
- if (formatPromise && typeof formatPromise.then === 'function') {
3550
- formatPromise.then(() => {
3551
- if (this._destroyed) return;
3552
- if (targetFile && this.files[targetFile] !== undefined) {
3553
- this._vfsWriteFile(targetFile, this.files[targetFile]);
3554
- if (this._savedSnapshot) this._savedSnapshot[targetFile] = this.files[targetFile];
3243
+ if (!this._savedSnapshot) this._savedSnapshot = {};
3244
+ const autoSaveMode = this.configuration
3245
+ ? this.configuration.get('files.autoSave', 'afterDelay')
3246
+ : 'afterDelay';
3247
+ if (saveAll || !targetFile || (autoSaveMode !== 'off' && autoSaveMode !== 'onFocusChange')) {
3248
+ this._savedSnapshot = { ...(this.files || {}) };
3249
+ this._clearFileDirty();
3250
+ this._saveState({ flushFiles: true });
3251
+ } else {
3252
+ if (this.files[targetFile] !== undefined) {
3253
+ this._savedSnapshot[targetFile] = this.files[targetFile];
3254
+ } else {
3255
+ delete this._savedSnapshot[targetFile];
3555
3256
  }
3556
- this._clearFileDirty(saveAll ? undefined : targetFile);
3257
+ this._clearFileDirty(targetFile);
3557
3258
  this._saveState({ flushSnapshotOnly: true });
3259
+ }
3260
+ };
3261
+ finalizeSave();
3262
+ if (formatPromise && typeof formatPromise.then === 'function') {
3263
+ formatPromise.then(() => {
3264
+ if (!this._destroyed) finalizeSave();
3558
3265
  }).catch((err) => {
3559
3266
  this.logger.debug('Async formatOnSave completion skipped.', err);
3560
3267
  });
@@ -3686,15 +3393,14 @@ int main() {
3686
3393
  if (project.gitMeta && typeof project.gitMeta === 'object' && typeof this._restoreSavedGitState === 'function') {
3687
3394
  this._restoreSavedGitState(project.gitMeta);
3688
3395
  } else if (project.gitFiles && root.CodeLabScm && typeof root.CodeLabScm.hydrateFromIsoGitRepo === 'function' && this.shell && this.shell.vfs) {
3689
- const gs = this._getGitState();
3690
- if (gs) {
3691
- Promise.resolve(root.CodeLabScm.hydrateFromIsoGitRepo(this.shell.vfs, gs)).then((hydrated) => {
3692
- if (hydrated && !this._destroyed) {
3693
- if (this.activeSidebarView === 'scm') this._renderScmSidebar();
3694
- this._updateStatusBar();
3695
- }
3696
- }).catch((_e) => { void _e; });
3697
- }
3396
+ Promise.resolve(root.CodeLabScm.hydrateFromIsoGitRepo(this.shell.vfs, '/workspace')).then((hydrated) => {
3397
+ if (hydrated && !this._destroyed) {
3398
+ this._gitState = hydrated;
3399
+ if (this.shell) this.shell.gitState = hydrated;
3400
+ if (this.activeSidebarView === 'scm') this._renderScmSidebar();
3401
+ this._updateStatusBar();
3402
+ }
3403
+ }).catch((_e) => { void _e; });
3698
3404
  }
3699
3405
  this._buildSavedStateSnapshot({ flushFiles: true });
3700
3406
  this._syncAllModels();
@@ -3961,14 +3667,16 @@ int main() {
3961
3667
  if (probsTextEl) {
3962
3668
  let errs = 0;
3963
3669
  let warns = 0;
3670
+ let infos = 0;
3964
3671
  if (this._diagnosticsStore && typeof this._diagnosticsStore.getAll === 'function') {
3965
3672
  const storeItems = this._diagnosticsStore.getAll();
3966
3673
  for (const p of storeItems) {
3967
3674
  if (p && p.severity === 'error') errs++;
3968
3675
  else if (p && p.severity === 'warning') warns++;
3676
+ else if (p) infos++;
3969
3677
  }
3970
3678
  }
3971
- probsTextEl.textContent = `⊗ ${errs} ⚠ ${warns}`;
3679
+ probsTextEl.textContent = infos > 0 ? `⊗ ${errs} ⚠ ${warns} ⓘ ${infos}` : `⊗ ${errs} ⚠ ${warns}`;
3972
3680
  }
3973
3681
  const hasDirty = Boolean((this._dirtyFiles && this._dirtyFiles.size > 0) || this.saveStatusState === 'dirty');
3974
3682
  if (saveEl) {
@@ -4297,6 +4005,17 @@ int main() {
4297
4005
  this.container.querySelectorAll('[data-cl-action="run-code"], [data-cl-action="run-entry"], [data-cl-action="run-active-file"], [data-cl-action="run-demo"], [data-cl-action="run-tests"], [data-cl-action="verify-step"]').forEach(btn => {
4298
4006
  btn.disabled = this.isRunning;
4299
4007
  });
4008
+ if (this._xtermEngines instanceof Map && Array.isArray(this._terminalSessions)) {
4009
+ for (const sess of this._terminalSessions) {
4010
+ const eng = this._xtermEngines.get(sess.id);
4011
+ if (eng && typeof eng.setBusy === 'function') {
4012
+ const sessBusy = sess.id === this._activeTerminalSessionId
4013
+ ? Boolean(sess.isRunning || this.isRunning)
4014
+ : Boolean(sess.isRunning);
4015
+ eng.setBusy(sessBusy);
4016
+ }
4017
+ }
4018
+ }
4300
4019
  this._updatePtyActiveLine();
4301
4020
  }
4302
4021
 
@@ -4715,9 +4434,6 @@ int main() {
4715
4434
  <button type="button" class="codelab-btn codelab-btn--icon ${this.panelVisible ? 'active' : ''}" id="cl-toggle-drawer-btn" data-cl-action="toggle-drawer" title="Toggle Panel (⌘J)" aria-label="Toggle Panel" aria-pressed="${this.panelVisible ? 'true' : 'false'}">
4716
4435
  ${CL_ICONS.panelBottom}
4717
4436
  </button>
4718
- <button type="button" class="codelab-btn codelab-btn--icon" id="cl-settings-btn" data-cl-action="open-settings" title="Settings (⌘,)" aria-label="Open Settings">
4719
- ${CL_ICONS.settings}
4720
- </button>
4721
4437
  <button type="button" class="codelab-btn codelab-btn--icon" id="cl-fullscreen-btn" data-cl-action="toggle-fullscreen" title="Toggle Fullscreen IDE (Esc to exit)" aria-label="Toggle Fullscreen IDE">
4722
4438
  ${CL_ICONS.maximize}
4723
4439
  </button>
@@ -4736,25 +4452,25 @@ int main() {
4736
4452
  <nav class="codelab-activitybar" id="cl-activitybar" aria-label="Activity Bar">
4737
4453
  <div class="codelab-activitybar__top">
4738
4454
  <button type="button" class="codelab-activitybar__btn codelab-activitybar__item ${this.sidebarVisible && this.activeSidebarView === 'explorer' ? 'active' : ''}" data-cl-activity="explorer" title="Explorer (⇧⌘E)" aria-label="Explorer" aria-pressed="${this.sidebarVisible && this.activeSidebarView === 'explorer'}">
4739
- ${CL_ICONS.files}
4455
+ ${CL_ICONS.activityExplorer || CL_ICONS.files}
4740
4456
  </button>
4741
4457
  <button type="button" class="codelab-activitybar__btn codelab-activitybar__item ${this.sidebarVisible && this.activeSidebarView === 'search' ? 'active' : ''}" data-cl-activity="search" title="Search (⇧⌘F)" aria-label="Search" aria-pressed="${this.sidebarVisible && this.activeSidebarView === 'search'}">
4742
- ${CL_ICONS.search}
4458
+ ${CL_ICONS.activitySearch || CL_ICONS.search}
4743
4459
  </button>
4744
4460
  <button type="button" class="codelab-activitybar__btn codelab-activitybar__item ${this.sidebarVisible && this.activeSidebarView === 'scm' ? 'active' : ''}" data-cl-activity="scm" title="Source Control (⌃⇧G)" aria-label="Source Control" aria-pressed="${this.sidebarVisible && this.activeSidebarView === 'scm'}">
4745
- ${CL_ICONS.gitBranch}
4461
+ ${CL_ICONS.activityScm || CL_ICONS.gitBranch}
4746
4462
  <span class="codelab-activitybar__badge" id="cl-activity-scm-badge" hidden>0</span>
4747
4463
  </button>
4748
4464
  <div class="codelab-activitybar__plugins" id="cl-activitybar-plugins">${pluginSidebarBtnsHtml}</div>
4749
4465
  ${this.hasGuidedLab ? `
4750
4466
  <button type="button" class="codelab-activitybar__btn codelab-activitybar__item ${!isGuideCollapsed ? 'active' : ''}" data-cl-action="toggle-guide" title="Guided Lab Steps" aria-label="Guided Lab Steps" aria-pressed="${!isGuideCollapsed}">
4751
- ${CL_ICONS.book}
4467
+ ${CL_ICONS.activityGuided || CL_ICONS.book}
4752
4468
  </button>
4753
4469
  ` : ''}
4754
4470
  </div>
4755
4471
  <div class="codelab-activitybar__bottom">
4756
4472
  <button type="button" class="codelab-activitybar__btn codelab-activitybar__item ${this.activeTab === '__settings__' ? 'active' : ''}" data-cl-activity="settings" data-cl-action="open-settings" title="Settings (⌘,)" aria-label="Settings" aria-pressed="${this.activeTab === '__settings__'}">
4757
- ${CL_ICONS.settings}
4473
+ ${CL_ICONS.activitySettings || CL_ICONS.settings}
4758
4474
  </button>
4759
4475
  </div>
4760
4476
  </nav>
@@ -4910,9 +4626,9 @@ int main() {
4910
4626
  <span>Ports</span>
4911
4627
  <span class="codelab-drawer__pill" id="cl-ports-pill" style="display:${(this.portTable && typeof this.portTable.listServers === 'function' && this.portTable.listServers().length > 0) ? 'inline-flex' : 'none'}">${this.portTable && typeof this.portTable.listServers === 'function' ? this.portTable.listServers().length : 0} open</span>
4912
4628
  </button>
4913
- <button type="button" role="tab" tabindex="${this.drawerTab === 'tests' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'tests'}" class="codelab-drawer__tab ${this.drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests" style="${(isSingleSql && !this._findEntryFile('test')) ? 'display:none' : ''}">
4629
+ <button type="button" role="tab" tabindex="${this.drawerTab === 'tests' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'tests'}" class="codelab-drawer__tab ${this.drawerTab === 'tests' ? 'active' : ''}" data-cl-drawertab="tests" title="Test Suite" style="${(isSingleSql && !this._findEntryFile('test')) ? 'display:none' : ''}">
4914
4630
  ${CL_ICONS.check}
4915
- <span>Test Suite</span>
4631
+ <span>Tests</span>
4916
4632
  <span class="codelab-drawer__pill" id="cl-test-pill" style="display:none">Ready</span>
4917
4633
  </button>
4918
4634
  <button type="button" role="tab" tabindex="${this.drawerTab === 'stdin' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'stdin'}" class="codelab-drawer__tab ${this.drawerTab === 'stdin' ? 'active' : ''}" data-cl-drawertab="stdin" title="Standard Input" style="${isSingleSql ? 'display:none' : ''}">
@@ -4921,16 +4637,16 @@ int main() {
4921
4637
  </button>
4922
4638
  <button type="button" role="tab" tabindex="${this.drawerTab === 'preview' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'preview'}" class="codelab-drawer__tab ${this.drawerTab === 'preview' ? 'active' : ''}" data-cl-drawertab="preview" title="In-browser Web Preview" style="${isSingleSql ? 'display:none' : ''}">
4923
4639
  ${CL_ICONS.globe}
4924
- <span>Web Preview</span>
4640
+ <span>Preview</span>
4925
4641
  </button>
4926
4642
  <button type="button" role="tab" tabindex="${this.drawerTab === 'network' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'network'}" class="codelab-drawer__tab ${this.drawerTab === 'network' ? 'active' : ''}" data-cl-drawertab="network" style="${isSingleSql ? 'display:none' : ''}">
4927
4643
  ${CL_ICONS.activity}
4928
4644
  <span>Network</span>
4929
4645
  <span class="codelab-drawer__pill" id="cl-network-pill" style="display:${(this.lastHttpTrace || []).length > 0 ? 'inline-flex' : 'none'}">${(this.lastHttpTrace || []).length} reqs</span>
4930
4646
  </button>
4931
- <button type="button" role="tab" tabindex="${this.drawerTab === 'inspector' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'inspector'}" class="codelab-drawer__tab ${this.drawerTab === 'inspector' ? 'active' : ''}" data-cl-drawertab="inspector" style="${isSingleSql ? 'display:none' : ''}">
4647
+ <button type="button" role="tab" tabindex="${this.drawerTab === 'inspector' ? '0' : '-1'}" aria-selected="${this.drawerTab === 'inspector'}" class="codelab-drawer__tab ${this.drawerTab === 'inspector' ? 'active' : ''}" data-cl-drawertab="inspector" title="Virtual Disk &amp; HTTP Inspector" style="${isSingleSql ? 'display:none' : ''}">
4932
4648
  ${CL_ICONS.database}
4933
- <span>Virtual Disk &amp; HTTP</span>
4649
+ <span>Inspector</span>
4934
4650
  <span class="codelab-drawer__pill" id="cl-vfs-pill" style="display:none">0 files</span>
4935
4651
  </button>
4936
4652
  ${this.kernel ? `
@@ -5092,9 +4808,14 @@ int main() {
5092
4808
  }
5093
4809
  }
5094
4810
  const code = this.files[filePath];
5095
- if (_wbComponents && typeof _wbComponents.findEnclosingSymbolAtLine === 'function') {
4811
+ if (
4812
+ _wbComponents &&
4813
+ typeof _wbComponents.extractDocumentSymbols === 'function' &&
4814
+ typeof _wbComponents.findEnclosingSymbolAtLine === 'function'
4815
+ ) {
5096
4816
  const curLine = (this.cursorPos && this.cursorPos.lineNumber) ? this.cursorPos.lineNumber : 1;
5097
- const sym = _wbComponents.findEnclosingSymbolAtLine(filePath, code, curLine);
4817
+ const symbols = _wbComponents.extractDocumentSymbols(filePath, code);
4818
+ const sym = _wbComponents.findEnclosingSymbolAtLine(symbols, curLine);
5098
4819
  if (sym && sym.name) {
5099
4820
  return sym.containerName ? `${sym.containerName}.${sym.name}` : sym.name;
5100
4821
  }
@@ -5206,11 +4927,6 @@ int main() {
5206
4927
  </div>
5207
4928
  <div class="codelab-breadcrumbs__actions">
5208
4929
  ${diffBtnHtml}
5209
- <button type="button" class="codelab-breadcrumb__btn" data-action="command-palette" data-cl-action="command-palette" title="Open Command Palette (⌘⇧P)">
5210
- ${CL_ICONS.command}
5211
- <span>Command Palette</span>
5212
- <kbd class="codelab-breadcrumb__kbd">⌘⇧P</kbd>
5213
- </button>
5214
4930
  <button type="button" class="codelab-breadcrumb__btn" data-action="export-workspace" data-cl-action="export-workspace" title="Export Workspace Snapshot">
5215
4931
  ${CL_ICONS.download}
5216
4932
  <span>Export</span>
@@ -5741,11 +5457,16 @@ int main() {
5741
5457
  });
5742
5458
  });
5743
5459
 
5460
+ const isExternalFilesDrag = (ev) =>
5461
+ Boolean(ev.dataTransfer && ev.dataTransfer.types && Array.from(ev.dataTransfer.types).includes('Files'));
5462
+
5744
5463
  // Attach folder drop events
5745
5464
  explorerEl.querySelectorAll('.codelab-folder-item').forEach(el => {
5746
5465
  el.addEventListener('dragover', ev => {
5747
5466
  ev.preventDefault();
5748
- if (ev.dataTransfer) ev.dataTransfer.dropEffect = 'move';
5467
+ if (ev.dataTransfer) {
5468
+ ev.dataTransfer.dropEffect = isExternalFilesDrag(ev) ? 'copy' : 'move';
5469
+ }
5749
5470
  el.classList.add('drag-over');
5750
5471
  });
5751
5472
  el.addEventListener('dragleave', () => {
@@ -5755,23 +5476,42 @@ int main() {
5755
5476
  ev.preventDefault();
5756
5477
  ev.stopPropagation();
5757
5478
  el.classList.remove('drag-over');
5479
+ explorerEl.classList.remove('drag-over');
5480
+ const folder = el.dataset.clFolder || '';
5481
+ if (ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files.length > 0) {
5482
+ this.importDroppedFiles(ev.dataTransfer.files, folder);
5483
+ return;
5484
+ }
5758
5485
  const fileToMove = this._draggedFile || (ev.dataTransfer && ev.dataTransfer.getData('text/plain'));
5759
- const folder = el.dataset.clFolder;
5760
- if (fileToMove && folder !== undefined) {
5486
+ if (fileToMove && el.dataset.clFolder !== undefined) {
5761
5487
  this.moveFile(fileToMove, folder);
5762
5488
  }
5763
5489
  });
5764
5490
  });
5765
5491
 
5766
- // Explorer container drop target (for moving to workspace root)
5492
+ // Explorer container drop target (for moving to workspace root or importing OS files)
5767
5493
  if (!explorerEl._dragBound) {
5768
5494
  explorerEl._dragBound = true;
5769
5495
  explorerEl.addEventListener('dragover', ev => {
5770
5496
  ev.preventDefault();
5497
+ if (ev.dataTransfer && isExternalFilesDrag(ev)) {
5498
+ ev.dataTransfer.dropEffect = 'copy';
5499
+ explorerEl.classList.add('drag-over');
5500
+ }
5501
+ });
5502
+ explorerEl.addEventListener('dragleave', ev => {
5503
+ if (!ev.relatedTarget || !explorerEl.contains(ev.relatedTarget)) {
5504
+ explorerEl.classList.remove('drag-over');
5505
+ }
5771
5506
  });
5772
5507
  explorerEl.addEventListener('drop', ev => {
5508
+ explorerEl.classList.remove('drag-over');
5773
5509
  if (ev.target.closest && ev.target.closest('.codelab-folder-item')) return;
5774
5510
  ev.preventDefault();
5511
+ if (ev.dataTransfer && ev.dataTransfer.files && ev.dataTransfer.files.length > 0) {
5512
+ this.importDroppedFiles(ev.dataTransfer.files, '');
5513
+ return;
5514
+ }
5775
5515
  const fileToMove = this._draggedFile || (ev.dataTransfer && ev.dataTransfer.getData('text/plain'));
5776
5516
  if (fileToMove) {
5777
5517
  this.moveFile(fileToMove, '');
@@ -7398,18 +7138,34 @@ int main() {
7398
7138
  }
7399
7139
  }
7400
7140
 
7401
- _appendTerminalStream(type = 'stdout', chunk = '') {
7141
+ _getTerminalSessionById(sessionId) {
7142
+ const sessions = this._ensureTerminalSessions();
7143
+ if (sessionId) {
7144
+ return sessions.find((s) => s.id === sessionId) || null;
7145
+ }
7146
+ return sessions.find((s) => s.id === this._activeTerminalSessionId) || sessions[0] || null;
7147
+ }
7148
+
7149
+ _getXtermEngineForSessionId(sessionId) {
7150
+ if (!(this._xtermEngines instanceof Map)) return null;
7151
+ if (sessionId) return this._xtermEngines.get(sessionId) || null;
7152
+ return this._getActiveXtermEngine();
7153
+ }
7154
+
7155
+ _appendTerminalStream(type = 'stdout', chunk = '', sessionId = null) {
7402
7156
  if (chunk === null || chunk === undefined || chunk === '') return;
7403
7157
  const rawText = String(chunk);
7158
+ const targetSessionId = sessionId || this._activeTerminalSessionId || null;
7159
+ const isTargetActive = !targetSessionId || targetSessionId === this._activeTerminalSessionId;
7404
7160
 
7405
- const activeXterm = this._getActiveXtermEngine();
7406
- if (activeXterm && typeof activeXterm.writeStreamChunk === 'function') {
7161
+ const targetXterm = this._getXtermEngineForSessionId(targetSessionId);
7162
+ if (targetXterm && typeof targetXterm.writeStreamChunk === 'function') {
7407
7163
  try {
7408
- activeXterm.writeStreamChunk(rawText, type);
7164
+ targetXterm.writeStreamChunk(rawText, type);
7409
7165
  } catch (err) {
7410
- this.logger.debug('activeXterm.writeStreamChunk failed.', err);
7166
+ this.logger.debug('targetXterm.writeStreamChunk failed.', err);
7411
7167
  }
7412
- } else if (this.ptyEngine && this.ptyEngine.container && typeof this.ptyEngine.writeStreamChunk === 'function') {
7168
+ } else if (isTargetActive && this.ptyEngine && this.ptyEngine.container && typeof this.ptyEngine.writeStreamChunk === 'function') {
7413
7169
  try {
7414
7170
  this.ptyEngine.writeStreamChunk(rawText, type);
7415
7171
  } catch (err) {
@@ -7417,13 +7173,29 @@ int main() {
7417
7173
  }
7418
7174
  }
7419
7175
 
7176
+ if (!isTargetActive) {
7177
+ const targetSess = this._getTerminalSessionById(targetSessionId);
7178
+ if (targetSess && Array.isArray(targetSess.logs) && (!targetXterm || targetXterm.logs !== targetSess.logs)) {
7179
+ const lines = rawText.replace(/\r\n/g, '\n').split('\n');
7180
+ const maxSb = this._getTerminalScrollback();
7181
+ for (const line of lines) {
7182
+ if (line === '') continue;
7183
+ targetSess.logs.push({ type, text: line });
7184
+ }
7185
+ if (targetSess.logs.length > maxSb) {
7186
+ targetSess.logs.splice(0, targetSess.logs.length - maxSb);
7187
+ }
7188
+ }
7189
+ return;
7190
+ }
7191
+
7420
7192
  this._activeStreamType = type;
7421
7193
  const termLogEl = this.container ? this.container.querySelector('#cl-terminal-log') : null;
7422
7194
  const termSurface = this.container ? this.container.querySelector('#cl-terminal-surface') : null;
7423
7195
  const drawerBody = this.container ? this.container.querySelector('.codelab-drawer__body') : null;
7424
7196
 
7425
7197
  // The workbench owns live terminal rendering unless xterm or an attached PTY engine owns the DOM.
7426
- const ptyOwnsDom = Boolean((activeXterm && activeXterm.container) || (this.ptyEngine && this.ptyEngine.container));
7198
+ const ptyOwnsDom = Boolean((targetXterm && targetXterm.container) || (this.ptyEngine && this.ptyEngine.container));
7427
7199
  const canPatchDom = Boolean(termLogEl && typeof document !== 'undefined' && !ptyOwnsDom);
7428
7200
 
7429
7201
  // Write a single logical line into the live terminal DOM immediately, so output
@@ -7570,11 +7342,16 @@ int main() {
7570
7342
 
7571
7343
  _pushTerminalLog(entry, opts = null) {
7572
7344
  if (!entry) return;
7573
- const activeXterm = this._getActiveXtermEngine();
7574
- if (activeXterm && activeXterm.logs === this.terminalLogs) {
7575
- if (!(opts && opts.fromStream) && typeof activeXterm.writeln === 'function') {
7345
+ const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || null;
7346
+ const isTargetActive = !targetSessionId || targetSessionId === this._activeTerminalSessionId;
7347
+ const targetSess = isTargetActive ? null : this._getTerminalSessionById(targetSessionId);
7348
+ const targetLogs = targetSess && Array.isArray(targetSess.logs) ? targetSess.logs : this.terminalLogs;
7349
+ const targetXterm = this._getXtermEngineForSessionId(targetSessionId);
7350
+
7351
+ if (targetXterm && targetXterm.logs === targetLogs) {
7352
+ if (!(opts && opts.fromStream) && typeof targetXterm.writeln === 'function') {
7576
7353
  try {
7577
- activeXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7354
+ targetXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7578
7355
  } catch (_err) {
7579
7356
  void _err;
7580
7357
  }
@@ -7582,12 +7359,12 @@ int main() {
7582
7359
  this._trimTerminalLogs();
7583
7360
  return;
7584
7361
  }
7585
- if (Array.isArray(this.terminalLogs)) {
7586
- Array.prototype.push.call(this.terminalLogs, entry);
7362
+ if (Array.isArray(targetLogs)) {
7363
+ Array.prototype.push.call(targetLogs, entry);
7587
7364
  }
7588
- if (activeXterm && !(opts && opts.fromStream) && typeof activeXterm.writeln === 'function') {
7365
+ if (targetXterm && !(opts && opts.fromStream) && typeof targetXterm.writeln === 'function') {
7589
7366
  try {
7590
- activeXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7367
+ targetXterm.writeln(String(entry.text ?? ''), entry.type || 'stdout');
7591
7368
  } catch (_err) {
7592
7369
  void _err;
7593
7370
  }
@@ -7678,6 +7455,8 @@ int main() {
7678
7455
 
7679
7456
  _handleInterrupt(opts = null) {
7680
7457
  const fromXterm = Boolean(opts && opts.fromXterm);
7458
+ const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || null;
7459
+ const targetSession = this._getTerminalSessionById(targetSessionId);
7681
7460
  let didInterrupt = false;
7682
7461
  if (this._cloneInFlight || this._activeCloneAbortController) {
7683
7462
  this.cancelClone();
@@ -7694,38 +7473,51 @@ int main() {
7694
7473
  this.logger.debug('cancelWorkerExecution failed.', err);
7695
7474
  }
7696
7475
  }
7697
- const isCommandRunning = Boolean(this.isRunning || this._activeCommandAbortController || cancelledWorker);
7476
+ const sessionAbort = targetSession ? targetSession.abortController : null;
7477
+ const sessionRunning = Boolean(targetSession && targetSession.isRunning);
7478
+ const isActiveTarget = !targetSession || targetSession.id === this._activeTerminalSessionId;
7479
+ const activeAbort = sessionAbort || (isActiveTarget ? this._activeCommandAbortController : null);
7480
+ const isCommandRunning = Boolean(sessionRunning || activeAbort || (isActiveTarget && (this.isRunning || cancelledWorker)));
7698
7481
  const cwdShort = (this.cwd || '/workspace').replace(/^\/workspace\/?/, '') || '~';
7699
7482
  const promptLabel = this.inRepl ? '> ' : `codelab:${cwdShort}$`;
7700
7483
 
7701
7484
  if (isCommandRunning) {
7702
7485
  didInterrupt = true;
7703
- if (this._activeCommandAbortController) {
7486
+ if (activeAbort) {
7704
7487
  try {
7705
- this._activeCommandAbortController.abort('SIGINT');
7488
+ activeAbort.abort('SIGINT');
7706
7489
  } catch (err) {
7707
7490
  this.logger.debug('AbortController.abort failed.', err);
7708
7491
  }
7709
- this._activeCommandAbortController = null;
7492
+ if (targetSession && targetSession.abortController === activeAbort) {
7493
+ targetSession.abortController = null;
7494
+ }
7495
+ if (this._activeCommandAbortController === activeAbort) {
7496
+ this._activeCommandAbortController = null;
7497
+ }
7498
+ }
7499
+ if (targetSession) {
7500
+ targetSession.isRunning = false;
7501
+ }
7502
+ if (isActiveTarget) {
7503
+ this.isRunning = false;
7504
+ this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
7710
7505
  }
7711
-
7712
- this.isRunning = false;
7713
- this._setRuntimeStatus('idle', 'Ready · Node v22 VFS');
7714
7506
  this._updateRunStateUI();
7715
7507
 
7716
7508
  this._flushTerminalStream();
7717
7509
  if (!fromXterm) {
7718
- this._pushTerminalLog({ type: 'stdout', text: '^C' });
7510
+ this._pushTerminalLog({ type: 'stdout', text: '^C' }, { sessionId: targetSessionId });
7719
7511
  }
7720
7512
  } else {
7721
7513
  if (this.inRepl) {
7722
7514
  this.inRepl = false;
7723
7515
  if (!fromXterm) {
7724
- this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' });
7516
+ this._pushTerminalLog({ type: 'stdout', text: '^C\nExiting REPL...' }, { sessionId: targetSessionId });
7725
7517
  }
7726
7518
  } else if (!fromXterm) {
7727
7519
  const currentInput = (this._ptyInputBeforeCursor || '') + (this._ptyInputAfterCursor || '');
7728
- this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` });
7520
+ this._pushTerminalLog({ type: 'stdout', text: `${promptLabel} ${currentInput}^C` }, { sessionId: targetSessionId });
7729
7521
  }
7730
7522
  }
7731
7523
 
@@ -8874,13 +8666,13 @@ int main() {
8874
8666
  if (this._activeTerminalSessionId !== session.id) {
8875
8667
  this.switchTerminalSession(session.id);
8876
8668
  }
8877
- return this._handleReplCommand(cmd, { skipEcho: true });
8669
+ return this._handleReplCommand(cmd, { skipEcho: true, sessionId: session.id });
8878
8670
  },
8879
8671
  onInterrupt: () => {
8880
8672
  if (this._activeTerminalSessionId !== session.id) {
8881
8673
  this.switchTerminalSession(session.id);
8882
8674
  }
8883
- this._handleInterrupt({ fromXterm: true });
8675
+ this._handleInterrupt({ fromXterm: true, sessionId: session.id });
8884
8676
  },
8885
8677
  getCompletions: (buf, cur) => {
8886
8678
  const slice = String(buf || '').slice(0, typeof cur === 'number' ? cur : String(buf || '').length);
@@ -9759,7 +9551,7 @@ int main() {
9759
9551
  this._renderDrawerBody();
9760
9552
 
9761
9553
  try {
9762
- const res = await this.shell.execute(`serve ${rootDir}`, {});
9554
+ const res = await this.shell.execute(`serve ${rootDir}`, { isBackground: true });
9763
9555
  if (res && res.stdout) this._pushTerminalLog({ type: 'stdout', text: res.stdout.replace(/\n$/, '') });
9764
9556
  if (res && res.stderr) this._pushTerminalLog({ type: 'stderr', text: res.stderr.replace(/\n$/, '') });
9765
9557
  } catch (err) {
@@ -11648,6 +11440,17 @@ int main() {
11648
11440
  _bindEvents() {
11649
11441
  if (this._isBooting || this._eventsBound) return;
11650
11442
  this._eventsBound = true;
11443
+ if (Array.isArray(this._containerListeners) && this.container && typeof this.container.removeEventListener === 'function') {
11444
+ for (const [evType, evFn, evOpts] of this._containerListeners) {
11445
+ try { this.container.removeEventListener(evType, evFn, evOpts); } catch (_err) { void _err; }
11446
+ }
11447
+ }
11448
+ this._containerListeners = [];
11449
+ const onContainer = (type, fn, opts) => {
11450
+ if (!this.container || typeof this.container.addEventListener !== 'function') return;
11451
+ this.container.addEventListener(type, fn, opts);
11452
+ this._containerListeners.push([type, fn, opts]);
11453
+ };
11651
11454
 
11652
11455
  this._bindSplitters();
11653
11456
 
@@ -11883,7 +11686,7 @@ int main() {
11883
11686
  return;
11884
11687
  }
11885
11688
  };
11886
- this.container.addEventListener('keydown', this._captureKeydownHandler, true);
11689
+ onContainer('keydown', this._captureKeydownHandler, true);
11887
11690
  if (typeof document !== 'undefined' && typeof document.addEventListener === 'function') {
11888
11691
  this._documentKeydownHandler = e => {
11889
11692
  if (!e || e.defaultPrevented || this._destroyed) return;
@@ -11932,7 +11735,7 @@ int main() {
11932
11735
  document.addEventListener('keydown', this._documentKeydownHandler);
11933
11736
  }
11934
11737
 
11935
- this.container.addEventListener('pointerdown', e => {
11738
+ onContainer('pointerdown', e => {
11936
11739
  if (e && e.target && typeof e.target.closest === 'function' && e.target.closest('#cl-activitybar [data-cl-activity]')) {
11937
11740
  const ae = (typeof document !== 'undefined' && document.activeElement) ? document.activeElement : null;
11938
11741
  const focusInOtherRegion = Boolean(
@@ -11946,7 +11749,7 @@ int main() {
11946
11749
  }
11947
11750
  }, true);
11948
11751
 
11949
- this.container.addEventListener('pointerdown', e => {
11752
+ onContainer('pointerdown', e => {
11950
11753
  CodeLabWorkbench._lastActiveInstance = this;
11951
11754
  this._lastBackdropPointerDownTarget = (e && e.target) ? e.target : null;
11952
11755
  if (e && e.target && typeof e.target.closest === 'function' && e.target.closest('.codelab-menubar__trigger[data-cl-menu]')) {
@@ -11955,11 +11758,11 @@ int main() {
11955
11758
  this._menuOpenBeforePointerDown = undefined;
11956
11759
  }
11957
11760
  });
11958
- this.container.addEventListener('focusin', () => {
11761
+ onContainer('focusin', () => {
11959
11762
  CodeLabWorkbench._lastActiveInstance = this;
11960
11763
  });
11961
11764
 
11962
- this.container.addEventListener('mouseover', e => {
11765
+ onContainer('mouseover', e => {
11963
11766
  if (!e || !e.target || typeof e.target.closest !== 'function') return;
11964
11767
  if (this._activeTopMenu) {
11965
11768
  const trigger = e.target.closest('.codelab-menubar__trigger[data-cl-menu]');
@@ -11991,7 +11794,7 @@ int main() {
11991
11794
  }
11992
11795
  });
11993
11796
 
11994
- this.container.addEventListener('input', e => {
11797
+ onContainer('input', e => {
11995
11798
  if (!e || !e.target) return;
11996
11799
  const t = e.target;
11997
11800
  if (t.id === 'cl-search-input') {
@@ -12033,7 +11836,7 @@ int main() {
12033
11836
  }
12034
11837
  });
12035
11838
 
12036
- this.container.addEventListener('change', e => {
11839
+ onContainer('change', e => {
12037
11840
  if (!e || !e.target) return;
12038
11841
  const t = e.target;
12039
11842
  if (t.id === 'cl-scm-branch-select' && typeof t.value === 'string' && t.value) {
@@ -12043,7 +11846,7 @@ int main() {
12043
11846
  }
12044
11847
  });
12045
11848
 
12046
- this.container.addEventListener('keydown', e => {
11849
+ onContainer('keydown', e => {
12047
11850
  const keyLower = (e.key || '').toLowerCase();
12048
11851
  const target = e.target;
12049
11852
  const hasClosest = Boolean(target && typeof target.closest === 'function');
@@ -12592,7 +12395,7 @@ int main() {
12592
12395
  }
12593
12396
  });
12594
12397
 
12595
- this.container.addEventListener('contextmenu', e => {
12398
+ onContainer('contextmenu', e => {
12596
12399
  const tabEl = e.target.closest('.codelab-tab');
12597
12400
  if (tabEl && (tabEl.dataset.clFile || tabEl.dataset.tabFile)) {
12598
12401
  e.preventDefault();
@@ -12660,10 +12463,10 @@ int main() {
12660
12463
  }
12661
12464
  }
12662
12465
  };
12663
- this.container.addEventListener('auxclick', handleTabMiddleClick);
12664
- this.container.addEventListener('mousedown', handleTabMiddleClick);
12466
+ onContainer('auxclick', handleTabMiddleClick);
12467
+ onContainer('mousedown', handleTabMiddleClick);
12665
12468
 
12666
- this.container.addEventListener('click', e => {
12469
+ onContainer('click', e => {
12667
12470
  const menuCmdBtn = e.target.closest('[data-cl-menu-cmd]');
12668
12471
  if (menuCmdBtn) {
12669
12472
  e.stopPropagation();
@@ -13521,7 +13324,7 @@ int main() {
13521
13324
  }
13522
13325
  });
13523
13326
 
13524
- this.container.addEventListener('change', e => {
13327
+ onContainer('change', e => {
13525
13328
  const previewPortSelect = e.target && typeof e.target.closest === 'function'
13526
13329
  ? e.target.closest('[data-cl-action="preview-port-change"]')
13527
13330
  : null;
@@ -13806,6 +13609,7 @@ int main() {
13806
13609
  { id: 'toggle-guide', label: 'View: Toggle Guide Sidebar', action: () => this.toggleGuide() },
13807
13610
  { id: 'toggle-drawer', label: 'View: Toggle Panel Visibility', shortcut: '⌘J', action: () => this.togglePanel() },
13808
13611
  { id: 'toggle-terminal', label: 'View: Toggle Terminal', shortcut: '⌃`', action: () => this.toggleTerminal() },
13612
+ { id: 'toggle-zen-mode', label: 'View: Toggle Zen Mode', action: () => this.toggleZenMode() },
13809
13613
  { id: 'toggle-fullscreen', label: 'View: Toggle Fullscreen Workbench', action: () => this.toggleFullscreen() },
13810
13614
  { id: 'search-workspace', label: 'Search: Find & Replace Across Files...', shortcut: '⇧⌘F', action: () => this.openSearchView() },
13811
13615
  { id: 'open-scm', label: 'Git: Source Control (Status, Stage & Commit)...', shortcut: '⌃⇧G', action: () => this.openScmView() },
@@ -14903,6 +14707,91 @@ int main() {
14903
14707
  if (this.editor) setTimeout(() => this.editor.layout(), 50);
14904
14708
  }
14905
14709
 
14710
+ /**
14711
+ * Imports local OS files dropped into the Explorer into the workspace and VFS.
14712
+ */
14713
+ async importDroppedFiles(fileList, targetFolder = '') {
14714
+ const items = fileList ? Array.from(fileList) : [];
14715
+ if (items.length === 0) return [];
14716
+ const prefix = String(targetFolder || '').replace(/^\/+|\/+$/g, '');
14717
+ const reservedRe = /(?:^|\/)(?:\.git|node_modules)(?:\/|$)/;
14718
+ const MAX_FILE_BYTES = 2 * 1024 * 1024;
14719
+ const imported = [];
14720
+ let skipped = 0;
14721
+
14722
+ for (const file of items) {
14723
+ if (!file || typeof file.name !== 'string') continue;
14724
+ if (typeof file.size === 'number' && file.size > MAX_FILE_BYTES) {
14725
+ skipped++;
14726
+ continue;
14727
+ }
14728
+ const rawRel = (file.webkitRelativePath && String(file.webkitRelativePath).trim()) || file.name;
14729
+ const cleanRel = rawRel.replace(/\\/g, '/').replace(/^\/+/, '');
14730
+ const fullRel = prefix ? `${prefix}/${cleanRel}` : cleanRel;
14731
+ const normalized = this._normalizeWorkspaceRelPath(fullRel);
14732
+ if (!normalized || reservedRe.test(normalized)) {
14733
+ skipped++;
14734
+ continue;
14735
+ }
14736
+ try {
14737
+ const text = typeof file.text === 'function' ? await file.text() : String(file.content ?? '');
14738
+ this.files[normalized] = text;
14739
+ this._vfsWriteFile(normalized, text);
14740
+ imported.push(normalized);
14741
+ } catch (err) {
14742
+ this.logger.debug('Skipped unreadable dropped file.', normalized, err);
14743
+ skipped++;
14744
+ }
14745
+ }
14746
+
14747
+ if (imported.length > 0) {
14748
+ this._isBlankBase = false;
14749
+ this._syncAllModels();
14750
+ this._renderFileLists();
14751
+ this.openFile(imported[0]);
14752
+ this._saveState({ flushFiles: true });
14753
+ this._lintAllWorkspaceFiles();
14754
+ this._updateStatusBar();
14755
+ if (typeof this._showToast === 'function') {
14756
+ const extra = skipped > 0 ? ` (${skipped} skipped)` : '';
14757
+ this._showToast(`Imported ${imported.length} file${imported.length === 1 ? '' : 's'}${extra}`, 'success');
14758
+ }
14759
+ } else if (skipped > 0 && typeof this._showToast === 'function') {
14760
+ this._showToast(`Skipped ${skipped} unsupported or oversized file${skipped === 1 ? '' : 's'} (> 2 MB).`, 'warning');
14761
+ }
14762
+ return imported;
14763
+ }
14764
+
14765
+ /**
14766
+ * Toggles distraction-free Zen Mode by hiding sidebar, bottom panel, and status bar.
14767
+ */
14768
+ toggleZenMode() {
14769
+ const shell = this.container ? this.container.querySelector('.codelab') : null;
14770
+ if (!shell) return false;
14771
+ this.isZenMode = !this.isZenMode;
14772
+ if (this.isZenMode) {
14773
+ this._zenPriorState = {
14774
+ sidebarVisible: this.sidebarVisible !== false,
14775
+ panelVisible: this.panelVisible !== false
14776
+ };
14777
+ shell.classList.add('is-zen-mode');
14778
+ this.setSidebarVisible(false);
14779
+ this.setPanelVisible(false);
14780
+ if (typeof this._showToast === 'function') {
14781
+ this._showToast('Zen Mode enabled — run "View: Toggle Zen Mode" to exit', 'info');
14782
+ }
14783
+ } else {
14784
+ shell.classList.remove('is-zen-mode');
14785
+ const prior = this._zenPriorState || { sidebarVisible: true, panelVisible: true };
14786
+ this.setSidebarVisible(Boolean(prior.sidebarVisible));
14787
+ this.setPanelVisible(Boolean(prior.panelVisible));
14788
+ }
14789
+ if (this.editor && typeof this.editor.layout === 'function') {
14790
+ setTimeout(() => this.editor.layout(), 50);
14791
+ }
14792
+ return this.isZenMode;
14793
+ }
14794
+
14906
14795
  stopExecution() {
14907
14796
  this._handleInterrupt();
14908
14797
  }
@@ -16944,7 +16833,7 @@ int main() {
16944
16833
  if (!this._diagnosticsStore && diagMod && typeof diagMod.createDiagnosticsStore === 'function') {
16945
16834
  this._diagnosticsStore = diagMod.createDiagnosticsStore();
16946
16835
  if (typeof this._diagnosticsStore.subscribe === 'function') {
16947
- this._diagnosticsStore.subscribe(() => {
16836
+ this._diagnosticsUnsub = this._diagnosticsStore.subscribe(() => {
16948
16837
  if (this._destroyed || !this.container) return;
16949
16838
  const badgeEl = this.container.querySelector('#cl-problems-count');
16950
16839
  if (badgeEl && typeof this._diagnosticsStore.getAll === 'function') {
@@ -17629,31 +17518,56 @@ int main() {
17629
17518
  );
17630
17519
 
17631
17520
  if (this.shell && typeof this.shell.execute === 'function' && !looksLikeJsExpr) {
17521
+ const targetSessionId = (opts && opts.sessionId) || this._activeTerminalSessionId || 'session-1';
17522
+ const targetSession = this._getTerminalSessionById(targetSessionId);
17632
17523
  const abortCtrl = new AbortController();
17633
- this._activeCommandAbortController = abortCtrl;
17634
- this.isRunning = true;
17524
+ if (targetSession) {
17525
+ targetSession.abortController = abortCtrl;
17526
+ targetSession.isRunning = true;
17527
+ }
17528
+ if (targetSessionId === this._activeTerminalSessionId) {
17529
+ this._activeCommandAbortController = abortCtrl;
17530
+ this.isRunning = true;
17531
+ }
17635
17532
  this._updateRunStateUI();
17636
17533
  let streamedStdout = false;
17637
17534
  let streamedStderr = false;
17638
17535
 
17639
17536
  try {
17640
17537
  this._syncFilesToShellVfs();
17641
- this.shell.cwd = this.cwd || '/workspace';
17538
+ this.shell.cwd = (targetSession && targetSession.cwd) || this.cwd || '/workspace';
17539
+ if (targetSession) {
17540
+ if (!targetSession.env || typeof targetSession.env !== 'object') {
17541
+ targetSession.env = { ...this._getBaseShellEnv(), PWD: this.shell.cwd };
17542
+ }
17543
+ this.shell.env = { ...targetSession.env, PWD: this.shell.cwd };
17544
+ }
17642
17545
  const shellRes = await this.shell.execute(trimmed, {
17643
17546
  onStdout: (c) => {
17644
17547
  streamedStdout = true;
17645
- this._appendTerminalStream('stdout', c);
17548
+ this._appendTerminalStream('stdout', c, targetSessionId);
17646
17549
  },
17647
17550
  onStderr: (c) => {
17648
17551
  streamedStderr = true;
17649
- this._appendTerminalStream('stderr', c);
17552
+ this._appendTerminalStream('stderr', c, targetSessionId);
17650
17553
  },
17651
17554
  onRequestStdin: (promptText) => this._requestInteractiveTerminalStdin(promptText, abortCtrl.signal),
17652
17555
  signal: abortCtrl.signal
17653
17556
  });
17654
- this._flushTerminalStream();
17557
+ if (targetSessionId === this._activeTerminalSessionId) {
17558
+ this._flushTerminalStream();
17559
+ }
17655
17560
  const aborted = this._isAbortResult(shellRes, abortCtrl.signal);
17656
- this.cwd = this.shell.cwd || this.cwd;
17561
+ const nextCwd = this.shell.cwd || (targetSession && targetSession.cwd) || this.cwd;
17562
+ if (targetSession) {
17563
+ targetSession.cwd = nextCwd;
17564
+ if (this.shell && this.shell.env && typeof this.shell.env === 'object') {
17565
+ targetSession.env = { ...this.shell.env, PWD: nextCwd };
17566
+ }
17567
+ }
17568
+ if (targetSessionId === this._activeTerminalSessionId) {
17569
+ this.cwd = nextCwd;
17570
+ }
17657
17571
  this._syncVfsSnapshot(null, true);
17658
17572
  if (/^\s*git\b/.test(trimmed) || (this.shell && this.shell.gitState && this.shell.gitState.initialized)) {
17659
17573
  this._saveState();
@@ -17666,39 +17580,56 @@ int main() {
17666
17580
  this._updateStatusBar();
17667
17581
 
17668
17582
  if (shellRes && shellRes.clear) {
17669
- this._clearTerminalLogs();
17583
+ if (targetSessionId === this._activeTerminalSessionId) {
17584
+ this._clearTerminalLogs();
17585
+ } else if (targetSession) {
17586
+ targetSession.logs = [];
17587
+ }
17670
17588
  this._renderDrawerBody();
17671
17589
  return;
17672
17590
  }
17673
17591
  if (shellRes && shellRes.interactiveRepl) {
17674
- this.inRepl = true;
17592
+ if (targetSession) targetSession.inRepl = true;
17593
+ if (targetSessionId === this._activeTerminalSessionId) {
17594
+ this.inRepl = true;
17595
+ }
17675
17596
  if (shellRes.stdout && !streamedStdout) {
17676
- this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
17597
+ this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') }, { sessionId: targetSessionId });
17677
17598
  }
17678
17599
  this._renderDrawerBody();
17679
17600
  return;
17680
17601
  }
17681
17602
 
17682
17603
  if (!aborted && shellRes && shellRes.stdout && !streamedStdout) {
17683
- this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') });
17604
+ this._pushTerminalLog({ type: 'stdout', text: shellRes.stdout.replace(/\n$/, '') }, { sessionId: targetSessionId });
17684
17605
  }
17685
17606
  if (!aborted && shellRes && shellRes.stderr && !streamedStderr) {
17686
- this._pushTerminalLog({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') });
17607
+ this._pushTerminalLog({ type: 'stderr', text: shellRes.stderr.replace(/\n$/, '') }, { sessionId: targetSessionId });
17687
17608
  }
17688
17609
  this._renderDrawerBody();
17689
17610
  return;
17690
17611
  } catch (err) {
17691
- this._flushTerminalStream();
17612
+ if (targetSessionId === this._activeTerminalSessionId) {
17613
+ this._flushTerminalStream();
17614
+ }
17692
17615
  if (!(abortCtrl.signal.aborted || (err && err.name === 'AbortError'))) {
17693
- this._pushTerminalLog({ type: 'stderr', text: formatErrorText(err) });
17616
+ this._pushTerminalLog({ type: 'stderr', text: formatErrorText(err) }, { sessionId: targetSessionId });
17694
17617
  }
17695
17618
  this._renderDrawerBody();
17696
17619
  return;
17697
17620
  } finally {
17621
+ if (targetSession) {
17622
+ if (targetSession.abortController === abortCtrl) {
17623
+ targetSession.abortController = null;
17624
+ }
17625
+ targetSession.isRunning = false;
17626
+ }
17698
17627
  if (this._activeCommandAbortController === abortCtrl) {
17699
17628
  this._activeCommandAbortController = null;
17700
17629
  }
17701
- this.isRunning = false;
17630
+ if (targetSessionId === this._activeTerminalSessionId) {
17631
+ this.isRunning = false;
17632
+ }
17702
17633
  this._updateRunStateUI();
17703
17634
  }
17704
17635
  }
@@ -17998,9 +17929,9 @@ int main() {
17998
17929
  void _err;
17999
17930
  }
18000
17931
  }
18001
- if (this.kernel && this.kernel.fs && typeof this.kernel.fs.writeFileSync === 'function') {
17932
+ if (this.kernel && this.kernel.fs && typeof this.kernel.fs.writeFile === 'function') {
18002
17933
  try {
18003
- this.kernel.fs.writeFileSync(absPath, content);
17934
+ this.kernel.fs.writeFile(absPath, content);
18004
17935
  } catch (_err) {
18005
17936
  void _err;
18006
17937
  }
@@ -18168,9 +18099,9 @@ int main() {
18168
18099
  const restored = String(this.files[cleanRel] ?? '');
18169
18100
  if (this._dirtyFiles) this._dirtyFiles.delete(cleanRel);
18170
18101
  if (this._savedSnapshot) this._savedSnapshot[cleanRel] = restored;
18171
- if (this.kernel && this.kernel.fs && typeof this.kernel.fs.writeFileSync === 'function') {
18102
+ if (this.kernel && this.kernel.fs && typeof this.kernel.fs.writeFile === 'function') {
18172
18103
  try {
18173
- this.kernel.fs.writeFileSync(`/workspace/${cleanRel}`, restored);
18104
+ this.kernel.fs.writeFile(`/workspace/${cleanRel}`, restored);
18174
18105
  } catch (_err) {
18175
18106
  void _err;
18176
18107
  }
@@ -19335,6 +19266,7 @@ int main() {
19335
19266
  label: 'Appearance',
19336
19267
  submenu: [
19337
19268
  { label: 'Full Screen', cmd: 'view:fullscreen' },
19269
+ { label: 'Zen Mode', cmd: 'view:zen-mode' },
19338
19270
  { label: 'Move Primary Side Bar Left / Right', cmd: 'view:toggle-sidebar-side' },
19339
19271
  { label: 'Toggle Status Bar', cmd: 'view:toggle-statusbar' },
19340
19272
  { divider: true },
@@ -19611,6 +19543,8 @@ int main() {
19611
19543
  this.togglePanel();
19612
19544
  } else if (cmd === 'view:fullscreen') {
19613
19545
  this.toggleFullscreen();
19546
+ } else if (cmd === 'view:zen-mode') {
19547
+ this.toggleZenMode();
19614
19548
  } else if (cmd === 'view:toggle-sidebar-side') {
19615
19549
  if (this.configuration && typeof this.configuration.setUserSetting === 'function') {
19616
19550
  const cur = this.configuration.get('workbench.sidebar.defaultLocation', 'left');
@@ -20306,17 +20240,33 @@ int main() {
20306
20240
  }).join('');
20307
20241
  }
20308
20242
 
20243
+ _getBaseShellEnv() {
20244
+ if (!this._baseShellEnv && this.shell && this.shell.env && typeof this.shell.env === 'object') {
20245
+ this._baseShellEnv = { ...this.shell.env };
20246
+ }
20247
+ return this._baseShellEnv
20248
+ ? { ...this._baseShellEnv }
20249
+ : { HOME: '/workspace', PWD: '/workspace', PATH: '/usr/local/bin:/usr/bin:/bin' };
20250
+ }
20251
+
20309
20252
  _saveActiveTerminalSessionState() {
20310
20253
  if (!Array.isArray(this._terminalSessions)) return;
20311
20254
  const active = this._terminalSessions.find((s) => s.id === this._activeTerminalSessionId);
20312
20255
  if (!active) return;
20313
20256
  active.cwd = this.cwd || (this.shell && this.shell.cwd) || '/workspace';
20257
+ if (this.shell && this.shell.env && typeof this.shell.env === 'object') {
20258
+ active.env = { ...this.shell.env, PWD: active.cwd };
20259
+ }
20314
20260
  active.inRepl = Boolean(this.inRepl);
20315
20261
  active.replLang = this.replLang || 'node';
20316
20262
  active.replHistory = Array.isArray(this.replHistory) ? this.replHistory.slice() : [];
20317
20263
  active.replHistoryIdx = typeof this.replHistoryIdx === 'number' ? this.replHistoryIdx : -1;
20318
20264
  active.beforeCursor = this._ptyInputBeforeCursor || '';
20319
20265
  active.afterCursor = this._ptyInputAfterCursor || '';
20266
+ active.isRunning = Boolean(active.isRunning || this.isRunning);
20267
+ if (this._activeCommandAbortController && !active.abortController) {
20268
+ active.abortController = this._activeCommandAbortController;
20269
+ }
20320
20270
  if (Array.isArray(this.terminalLogs)) {
20321
20271
  active.logs = this.terminalLogs;
20322
20272
  }
@@ -20330,9 +20280,10 @@ int main() {
20330
20280
  this.cwd = target.cwd || '/workspace';
20331
20281
  if (this.shell) {
20332
20282
  this.shell.cwd = this.cwd;
20333
- if (this.shell.env && typeof this.shell.env === 'object') {
20334
- this.shell.env.PWD = this.cwd;
20283
+ if (!target.env || typeof target.env !== 'object') {
20284
+ target.env = { ...this._getBaseShellEnv(), PWD: this.cwd };
20335
20285
  }
20286
+ this.shell.env = { ...target.env, PWD: this.cwd };
20336
20287
  }
20337
20288
  this.inRepl = Boolean(target.inRepl);
20338
20289
  this.replLang = target.replLang || 'node';
@@ -20340,15 +20291,22 @@ int main() {
20340
20291
  this.replHistoryIdx = typeof target.replHistoryIdx === 'number' ? target.replHistoryIdx : -1;
20341
20292
  this._ptyInputBeforeCursor = target.beforeCursor || '';
20342
20293
  this._ptyInputAfterCursor = target.afterCursor || '';
20294
+ this.isRunning = Boolean(target.isRunning);
20295
+ this._activeCommandAbortController = target.abortController || null;
20296
+ if (typeof this._updateRunStateUI === 'function') {
20297
+ this._updateRunStateUI();
20298
+ }
20343
20299
  }
20344
20300
 
20345
20301
  _ensureTerminalSessions() {
20346
20302
  if (!Array.isArray(this._terminalSessions) || this._terminalSessions.length === 0) {
20303
+ const initCwd = this.cwd || (this.shell && this.shell.cwd) || '/workspace';
20347
20304
  this._terminalSessions = [
20348
20305
  {
20349
20306
  id: 'session-1',
20350
20307
  name: 'bash-1',
20351
- cwd: this.cwd || (this.shell && this.shell.cwd) || '/workspace',
20308
+ cwd: initCwd,
20309
+ env: { ...this._getBaseShellEnv(), PWD: initCwd },
20352
20310
  logs: Array.isArray(this.terminalLogs) ? this.terminalLogs : (this.terminalLogs = []),
20353
20311
  inRepl: Boolean(this.inRepl),
20354
20312
  replLang: this.replLang || 'node',
@@ -20386,6 +20344,7 @@ int main() {
20386
20344
  id,
20387
20345
  name: label,
20388
20346
  cwd: '/workspace',
20347
+ env: { ...this._getBaseShellEnv(), PWD: '/workspace' },
20389
20348
  logs: [],
20390
20349
  inRepl: false,
20391
20350
  replLang: 'node',
@@ -20458,6 +20417,11 @@ int main() {
20458
20417
 
20459
20418
  this._saveActiveTerminalSessionState();
20460
20419
  const removed = sessions.splice(idx, 1)[0];
20420
+ if (removed && removed.abortController) {
20421
+ try { removed.abortController.abort('SIGINT'); } catch (_err) { void _err; }
20422
+ removed.abortController = null;
20423
+ removed.isRunning = false;
20424
+ }
20461
20425
  if (this._xtermEngines instanceof Map && removed) {
20462
20426
  const oldEng = this._xtermEngines.get(removed.id);
20463
20427
  if (oldEng && typeof oldEng.destroy === 'function') {
@@ -21402,6 +21366,16 @@ int main() {
21402
21366
  }
21403
21367
  this._portToasts.clear();
21404
21368
  }
21369
+ if (typeof this._diagnosticsUnsub === 'function') {
21370
+ try { this._diagnosticsUnsub(); } catch (_err) { void _err; }
21371
+ this._diagnosticsUnsub = null;
21372
+ }
21373
+ if (Array.isArray(this._containerListeners) && this.container && typeof this.container.removeEventListener === 'function') {
21374
+ for (const [evType, evFn, evOpts] of this._containerListeners) {
21375
+ try { this.container.removeEventListener(evType, evFn, evOpts); } catch (_err) { void _err; }
21376
+ }
21377
+ this._containerListeners = [];
21378
+ }
21405
21379
  if (this._markerDisposable && typeof this._markerDisposable.dispose === 'function') {
21406
21380
  try { this._markerDisposable.dispose(); } catch (err) { this.logger.debug('markerDisposable dispose skipped.', err); }
21407
21381
  this._markerDisposable = null;
@@ -21711,6 +21685,8 @@ int main() {
21711
21685
  openSettings(opts) { if (this._instance) this._instance.openSettings(opts); }
21712
21686
  closeSettings() { if (this._instance) this._instance.closeSettings(); }
21713
21687
  openWorkspaceSettingsJson() { if (this._instance) this._instance.openWorkspaceSettingsJson(); }
21688
+ toggleZenMode() { return this._instance ? this._instance.toggleZenMode() : false; }
21689
+ importDroppedFiles(fileList, targetFolder = '') { return this._instance ? this._instance.importDroppedFiles(fileList, targetFolder) : Promise.resolve([]); }
21714
21690
  runSql(mode, payload) { return this._instance ? this._instance.runSql(mode, payload) : Promise.resolve(null); }
21715
21691
  setSqlSchema(schema) { if (this._instance) this._instance.setSqlSchema(schema); return this; }
21716
21692
  setSqlDialect(dialect) { if (this._instance) this._instance.setSqlDialect(dialect); return this; }