Skip to content

Commit e1c12c6

Browse files
committed
redact logs
1 parent 8a4b506 commit e1c12c6

File tree

1 file changed

+18
-66
lines changed

1 file changed

+18
-66
lines changed

src/notebooks/deepnote/deepnoteCellCopyHandler.ts

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
9393
private async copyCellInterceptor(): Promise<void> {
9494
const editor = window.activeNotebookEditor;
9595
if (editor && editor.notebook && editor.notebook.notebookType === 'deepnote') {
96-
await this.copyCellToClipboard(false);
96+
await this.copyCellToClipboard({ isCut: false });
9797
} else {
9898
logger.warn('notebook.cell.copy intercepted for non-Deepnote notebook - using fallback');
9999
}
@@ -106,7 +106,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
106106
private async cutCellInterceptor(): Promise<void> {
107107
const editor = window.activeNotebookEditor;
108108
if (editor && editor.notebook && editor.notebook.notebookType === 'deepnote') {
109-
await this.copyCellToClipboard(true);
109+
await this.copyCellToClipboard({ isCut: true });
110110
} else {
111111
logger.warn('notebook.cell.cut intercepted for non-Deepnote notebook - using fallback');
112112
}
@@ -160,32 +160,11 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
160160
cellToCopy.document.languageId
161161
);
162162

163-
// Copy all metadata, but generate new ID and sortingKey
163+
// Copy all metadata (ID and sortingKey will be generated by onDidChangeNotebookDocument)
164164
if (cellToCopy.metadata) {
165165
const copiedMetadata = { ...cellToCopy.metadata };
166-
167-
// Generate new unique ID
168-
copiedMetadata.id = generateBlockId();
169-
170-
// Update sortingKey in pocket if it exists
171-
if (copiedMetadata.__deepnotePocket) {
172-
copiedMetadata.__deepnotePocket = {
173-
...copiedMetadata.__deepnotePocket,
174-
sortingKey: generateSortingKey(insertIndex)
175-
};
176-
} else if (copiedMetadata.sortingKey) {
177-
copiedMetadata.sortingKey = generateSortingKey(insertIndex);
178-
}
179-
180166
newCell.metadata = copiedMetadata;
181-
182-
logger.info(
183-
`DeepnoteCellCopyHandler: Copying cell with metadata preserved: ${JSON.stringify(
184-
copiedMetadata,
185-
null,
186-
2
187-
)}`
188-
);
167+
logger.debug('DeepnoteCellCopyHandler: Copying cell with metadata preserved');
189168
}
190169

191170
// Copy outputs if present
@@ -202,7 +181,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
202181
if (success) {
203182
// Move selection to the new cell
204183
editor.selection = new NotebookRange(insertIndex, insertIndex + 1);
205-
logger.info(`DeepnoteCellCopyHandler: Successfully copied cell to index ${insertIndex}`);
184+
logger.debug(`DeepnoteCellCopyHandler: Successfully copied cell to index ${insertIndex}`);
206185
} else {
207186
logger.warn('DeepnoteCellCopyHandler: Failed to copy cell');
208187
}
@@ -237,7 +216,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
237216
const metadata = cell.metadata || {};
238217

239218
// Log the metadata to see what's actually being copied
240-
logger.info(`DeepnoteCellCopyHandler: Cell added with metadata: ${JSON.stringify(metadata, null, 2)}`);
219+
logger.debug('DeepnoteCellCopyHandler: Cell added with metadata');
241220

242221
// Only process Deepnote cells (cells with type or pocket metadata)
243222
if (!metadata.type && !metadata.__deepnotePocket) {
@@ -273,10 +252,8 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
273252
metadata: updatedMetadata
274253
});
275254

276-
logger.info(
277-
`DeepnoteCellCopyHandler: Updated metadata for ${
278-
metadata.type
279-
} cell at index ${cellIndex}: ${JSON.stringify(updatedMetadata, null, 2)}`
255+
logger.debug(
256+
`DeepnoteCellCopyHandler: Updated metadata for ${metadata.type} cell at index ${cellIndex}`
280257
);
281258
}
282259

@@ -303,7 +280,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
303280
const success = await workspace.applyEdit(edit);
304281

305282
if (success) {
306-
logger.info(`DeepnoteCellCopyHandler: Successfully updated metadata for ${fixes.length} cell(s)`);
283+
logger.debug(`DeepnoteCellCopyHandler: Successfully updated metadata for ${fixes.length} cell(s)`);
307284
} else {
308285
logger.warn(`DeepnoteCellCopyHandler: Failed to apply metadata fixes for ${fixes.length} cell(s)`);
309286
}
@@ -318,7 +295,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
318295
* Copy or cut a cell to the clipboard with metadata preserved.
319296
* @param isCut Whether this is a cut operation (will delete the cell after copying)
320297
*/
321-
private async copyCellToClipboard(isCut: boolean): Promise<void> {
298+
private async copyCellToClipboard(params: { isCut: boolean }): Promise<void> {
322299
const editor = window.activeNotebookEditor;
323300

324301
if (!editor || !editor.notebook || editor.notebook.notebookType !== 'deepnote') {
@@ -345,22 +322,16 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
345322
const clipboardText = `${CLIPBOARD_MARKER}${JSON.stringify(clipboardData)}`;
346323
await env.clipboard.writeText(clipboardText);
347324

348-
logger.info(
349-
`DeepnoteCellCopyHandler: ${isCut ? 'Cut' : 'Copied'} cell to clipboard with metadata: ${JSON.stringify(
350-
clipboardData.metadata,
351-
null,
352-
2
353-
)}`
354-
);
325+
logger.debug(`DeepnoteCellCopyHandler: ${params.isCut ? 'Cut' : 'Copied'} cell to clipboard with metadata`);
355326

356327
// If this is a cut operation, delete the cell
357-
if (isCut) {
328+
if (params.isCut) {
358329
const edit = new WorkspaceEdit();
359330
edit.set(editor.notebook.uri, [
360331
NotebookEdit.deleteCells(new NotebookRange(selection.start, selection.start + 1))
361332
]);
362333
await workspace.applyEdit(edit);
363-
logger.info(`DeepnoteCellCopyHandler: Deleted cell after cut operation`);
334+
logger.debug(`DeepnoteCellCopyHandler: Deleted cell after cut operation`);
364335
}
365336
}
366337

@@ -385,7 +356,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
385356

386357
// Check if clipboard contains our metadata marker
387358
if (!clipboardText.startsWith(CLIPBOARD_MARKER)) {
388-
logger.info('DeepnoteCellCopyHandler: Clipboard does not contain Deepnote cell metadata, skipping');
359+
logger.debug('DeepnoteCellCopyHandler: Clipboard does not contain Deepnote cell metadata, skipping');
389360
return;
390361
}
391362

@@ -397,32 +368,13 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
397368
// Create new cell with preserved metadata
398369
const newCell = new NotebookCellData(clipboardData.kind, clipboardData.value, clipboardData.languageId);
399370

400-
// Copy metadata but generate new ID and sortingKey
401-
const copiedMetadata = { ...clipboardData.metadata };
402-
403-
// Generate new unique ID
404-
copiedMetadata.id = generateBlockId();
405-
406-
// Update sortingKey in pocket if it exists
407371
const insertIndex = selection.start;
408-
if (copiedMetadata.__deepnotePocket) {
409-
copiedMetadata.__deepnotePocket = {
410-
...copiedMetadata.__deepnotePocket,
411-
sortingKey: generateSortingKey(insertIndex)
412-
};
413-
} else if (copiedMetadata.sortingKey) {
414-
copiedMetadata.sortingKey = generateSortingKey(insertIndex);
415-
}
416372

373+
// Copy metadata (ID and sortingKey will be generated by onDidChangeNotebookDocument)
374+
const copiedMetadata = { ...clipboardData.metadata };
417375
newCell.metadata = copiedMetadata;
418376

419-
logger.info(
420-
`DeepnoteCellCopyHandler: Pasting cell with metadata preserved: ${JSON.stringify(
421-
copiedMetadata,
422-
null,
423-
2
424-
)}`
425-
);
377+
logger.debug('DeepnoteCellCopyHandler: Copying cell with metadata preserved');
426378

427379
// Insert the new cell
428380
const edit = new WorkspaceEdit();
@@ -433,7 +385,7 @@ export class DeepnoteCellCopyHandler implements IExtensionSyncActivationService
433385
if (success) {
434386
// Move selection to the new cell
435387
editor.selection = new NotebookRange(insertIndex, insertIndex + 1);
436-
logger.info(`DeepnoteCellCopyHandler: Successfully pasted cell at index ${insertIndex}`);
388+
logger.debug(`DeepnoteCellCopyHandler: Successfully pasted cell at index ${insertIndex}`);
437389
} else {
438390
logger.warn('DeepnoteCellCopyHandler: Failed to paste cell');
439391
}

0 commit comments

Comments
 (0)