Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ on:
default: ''
type: string
dry-run:
description: 'Build and validate artifacts without publishing, tagging, or committing'
description: 'Validate selected release artifacts without publishing, tagging, or committing'
required: true
default: true
type: boolean
Expand All @@ -76,7 +76,7 @@ jobs:
exclude-web-vsix: 'true'
extensions-root: .
vsix-artifact-name: vsix-packages
required-ci-checks: E2E
required-ci-checks: E2E / Web E2E, E2E / Desktop E2E (macos-latest), E2E / Desktop E2E (windows-latest)
node-version: '24'
package-manager: pnpm
package-manager-version: '10'
Expand Down
2 changes: 1 addition & 1 deletion lana/src/AppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
* Copyright (c) 2022 Certinia Inc. All rights reserved.
*/

export const appName = 'Lana';
export const appName = 'Salesforce Apex Log Analyzer';
4 changes: 2 additions & 2 deletions lana/src/commands/LogView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class LogView {
if (destinationFile) {
writeFile(destinationFile, fileContent).then(undefined, (error) => {
const msg = error instanceof Error ? error.message : String(error);
vscWindow.showErrorMessage(`Unable to save file: ${msg}`);
context.display.showErrorMessage(`Unable to save file: ${msg}`);
});
}
}
Expand All @@ -202,7 +202,7 @@ export class LogView {

case 'goToLogLine': {
if (isTimestampPayload(payload) && logUri) {
RawLogNavigation.goToLineByTimestamp(logUri, payload.timestamp);
RawLogNavigation.goToLineByTimestamp(logUri, payload.timestamp, context.display);
}
break;
}
Expand Down
43 changes: 42 additions & 1 deletion lana/src/commands/__tests__/RetrieveLogFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('RetrieveLogFile', () => {
RetrieveLogFile.apply(mockContext as unknown as import('../../Context.js').Context);

expect(mockContext.display.output).toHaveBeenCalledWith(
"Registered command 'Lana: Retrieve Log'",
"Registered command 'Salesforce Apex Log Analyzer: Retrieve Log'",
);
});
});
Expand Down Expand Up @@ -735,6 +735,47 @@ describe('RetrieveLogFile', () => {
});

describe('writeLogFile', () => {
it('preserves the memfs URI through the deferred log write', async () => {
const workspaceUri = Uri.parse('memfs:/test/workspace');
const testWs = new VSWorkspace({
uri: workspaceUri,
name: 'test-workspace',
index: 0,
});
mockPickOrReturn.mockResolvedValue(testWs);
mockListLogs.mockResolvedValue([
{
Id: 'download-me',
LogUser: { Name: 'User' },
Operation: 'Op',
LogLength: 1024,
DurationMilliseconds: 100,
StartTime: '2024-01-01T00:00:00.000Z',
Status: 'Success',
},
]);
mockQuickPickPick.mockResolvedValue([{ logId: 'download-me' }]);
mockFileOrFolderExists.mockResolvedValue(false);
mockGetLogBody.mockResolvedValue('fetched body');
mockWriteFile.mockResolvedValue(undefined);
mockCreateView.mockResolvedValue({ panel: 'mock' });

const mockContext = createMockContext();
RetrieveLogFile.apply(mockContext as unknown as import('../../Context.js').Context);

const lastCall = mockRegisterCommand.mock.calls[mockRegisterCommand.mock.calls.length - 1];
await lastCall[1]();

const [, writeLogFile, logUri] = mockCreateView.mock.calls[0];
await writeLogFile;

expect(logUri).toEqual(
Uri.parse('memfs:/test/workspace/.sfdx/tools/debug/logs/download-me.log'),
);
expect(mockFileOrFolderExists).toHaveBeenCalledWith(logUri);
expect(mockWriteFile).toHaveBeenCalledWith(logUri, 'fetched body');
});

it('should call getLogBody + writeFile when file does not exist', async () => {
const testWs = new VSWorkspace({
uri: Uri.parse('file:///test/ws'),
Expand Down
2 changes: 1 addition & 1 deletion lana/src/commands/__tests__/SwitchTimelineTheme.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ describe('SwitchTimelineTheme', () => {
SwitchTimelineTheme.apply(mockContext as unknown as import('../../Context.js').Context);

expect(mockContext.display.output).toHaveBeenCalledWith(
"Registered command 'Lana: Timeline Theme'",
"Registered command 'Salesforce Apex Log Analyzer: Timeline Theme'",
);
});
});
Expand Down
1 change: 1 addition & 0 deletions lana/src/display/Display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class Display {
}

showErrorMessage(s: string, options: MessageOptions = {}): void {
this.output(s, true);
window.showErrorMessage(s, options);
}

Expand Down
20 changes: 20 additions & 0 deletions lana/src/display/__tests__/Display.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2026 Certinia Inc. All rights reserved.
*/
import { describe, expect, it } from '@jest/globals';
import { window } from 'vscode';

import { Display } from '../Display.js';

describe('Display', () => {
it('writes errors to the output channel before displaying them', () => {
const display = new Display();
const outputChannel = (window.createOutputChannel as jest.Mock).mock.results.at(-1)?.value;

display.showErrorMessage('Unable to read log');

expect(outputChannel.appendLine).toHaveBeenCalledWith('Unable to read log');
expect(outputChannel.show).toHaveBeenCalledWith(true);
expect(window.showErrorMessage).toHaveBeenCalledWith('Unable to read log', {});
});
});
14 changes: 12 additions & 2 deletions lana/src/log-features/RawLogNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Selection, commands, window, type Uri } from 'vscode';

import { readFile } from '../services/salesforceServices.js';
import type { Display } from '../display/Display.js';

/**
* Handles navigation within raw Apex log files.
Expand All @@ -17,7 +18,11 @@ export class RawLogNavigation {
* @param logUri - URI of the log file (works on desktop file:// and web vscode-vfs://)
* @param timestamp - Nanosecond timestamp to find (from log event)
*/
public static async goToLineByTimestamp(logUri: Uri, timestamp: number): Promise<void> {
public static async goToLineByTimestamp(
logUri: Uri,
timestamp: number,
display?: Display,
): Promise<void> {
try {
// Read file (no normalization - avoids doubling memory for large files)
const text = await readFile(logUri);
Expand Down Expand Up @@ -51,7 +56,12 @@ export class RawLogNavigation {
});
} catch (error) {
const msg = error instanceof Error ? error.message : String(error);
window.showErrorMessage(`Unable to navigate to log line: ${msg}`);
const errorMessage = `Unable to navigate to log line: ${msg}`;
if (display) {
display.showErrorMessage(errorMessage);
} else {
window.showErrorMessage(errorMessage);
}
}
}
}
40 changes: 40 additions & 0 deletions lana/src/services/__tests__/salesforceServices.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2026 Certinia Inc. All rights reserved.
*/
import { beforeEach, describe, expect, it } from '@jest/globals';
import { Uri } from 'vscode';

const mockFsService = {
readFile: jest.fn(),
safeWriteFile: jest.fn(),
fileOrFolderExists: jest.fn(),
};
const mockRunPromise = jest.fn((effect: unknown) => Promise.resolve(effect));

jest.mock('../servicesRuntime.js', () => ({
getServicesApi: () => ({ services: { FsService: mockFsService } }),
getRuntime: () => ({ runPromise: mockRunPromise }),
}));

import { fileOrFolderExists, readFile, writeFile } from '../salesforceServices.js';

describe('salesforceServices filesystem adapters', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('passes a virtual filesystem URI directly to FsService', async () => {
const uri = Uri.parse('memfs:/test/workspace/log.log');
mockFsService.readFile.mockReturnValueOnce('log content');
mockFsService.safeWriteFile.mockReturnValueOnce(undefined);
mockFsService.fileOrFolderExists.mockReturnValueOnce(true);

await expect(readFile(uri)).resolves.toBe('log content');
await expect(writeFile(uri, 'updated log')).resolves.toBeUndefined();
await expect(fileOrFolderExists(uri)).resolves.toBe(true);

expect(mockFsService.readFile).toHaveBeenCalledWith(uri);
expect(mockFsService.safeWriteFile).toHaveBeenCalledWith(uri, 'updated log');
expect(mockFsService.fileOrFolderExists).toHaveBeenCalledWith(uri);
});
});
6 changes: 3 additions & 3 deletions lana/src/services/salesforceServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ export function getLogBody(logId: string): Promise<string> {
/** Read a file as UTF-8 text (web-safe via vscode.workspace.fs). */
export function readFile(uri: Uri | string): Promise<string> {
const { FsService } = getServicesApi().services;
return getRuntime().runPromise(FsService.readFile(uri.toString()));
return getRuntime().runPromise(FsService.readFile(uri));
}

/** Write UTF-8 text to a file, creating parent directories if needed. */
export function writeFile(uri: Uri | string, content: string): Promise<void> {
const { FsService } = getServicesApi().services;
return getRuntime().runPromise(FsService.safeWriteFile(uri.toString(), content));
return getRuntime().runPromise(FsService.safeWriteFile(uri, content));
}

/** True if the file or folder exists. */
export function fileOrFolderExists(uri: Uri | string): Promise<boolean> {
const { FsService } = getServicesApi().services;
return getRuntime().runPromise(FsService.fileOrFolderExists(uri.toString()));
return getRuntime().runPromise(FsService.fileOrFolderExists(uri));
}

/** Find files matching a glob, honoring the active (desktop or web) filesystem. */
Expand Down
Loading