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
8 changes: 8 additions & 0 deletions packages/workspace-server/src/services/os/os.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ describe("OsService simple delegations", () => {
await service.openExternal("https://posthog.com");
expect(urlLauncher.launch).toHaveBeenCalledWith("https://posthog.com");
});

it("opens the log folder as a file URL via the url launcher", async () => {
const { service, urlLauncher } = createService();
await service.showLogFolder();
expect(urlLauncher.launch).toHaveBeenCalledWith(
expect.stringMatching(/^file:\/\//),
);
Comment on lines +166 to +168

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The assertion only checks the file:// protocol prefix, but the mock already sets logFolderPath: "/logs" — a deterministic value. On any platform pathToFileURL("/logs").href returns "file:///logs", so the test could assert the complete URL and thereby also verify that the correct path was forwarded to pathToFileURL. As written, the test would pass even if showLogFolder called pathToFileURL("") or any other path.

Suggested change
expect(urlLauncher.launch).toHaveBeenCalledWith(
expect.stringMatching(/^file:\/\//),
);
expect(urlLauncher.launch).toHaveBeenCalledWith("file:///logs");

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

});
});

describe("OsService.getClaudePermissions", () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/workspace-server/src/services/os/os.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { APP_META_SERVICE, type IAppMeta } from "@posthog/platform/app-meta";
import {
DIALOG_SERVICE,
Expand Down Expand Up @@ -169,7 +170,9 @@ export class OsService {
}

async showLogFolder(): Promise<void> {
await this.urlLauncher.launch(`file://${this.storagePaths.logFolderPath}`);
await this.urlLauncher.launch(
pathToFileURL(this.storagePaths.logFolderPath).href,
);
}

async searchDirectories(query: string): Promise<string[]> {
Expand Down
Loading