Skip to content

Commit 52f2918

Browse files
committed
Handle review comments
1 parent c730b24 commit 52f2918

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### Added
6+
7+
- Proxy log directory now defaults to the extension's global storage when `coder.proxyLogDirectory`
8+
is not set, so SSH connection logs are always captured without manual configuration. Also respects
9+
the `CODER_SSH_LOG_DIR` environment variable as a fallback.
10+
511
## [v1.14.0-pre](https://github.com/coder/vscode-coder/releases/tag/v1.14.0-pre) 2026-03-06
612

713
### Added

src/commands.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ export class Commands {
148148
public async viewLogs(): Promise<void> {
149149
if (this.workspaceLogPath) {
150150
// Return the connected deployment's log file.
151-
return this.openFile(this.workspaceLogPath);
151+
return openFile(this.workspaceLogPath);
152152
}
153153

154154
const logDir = this.pathResolver.getProxyLogPath();
155155
try {
156-
const files = await fs.readdir(logDir);
156+
const files = await readdirOrEmpty(logDir);
157157
// Sort explicitly since fs.readdir order is platform-dependent
158158
const logFiles = files
159159
.filter((f) => f.endsWith(".log"))
@@ -172,7 +172,7 @@ export class Commands {
172172
});
173173

174174
if (selected) {
175-
await this.openFile(path.join(logDir, selected));
175+
await openFile(path.join(logDir, selected));
176176
}
177177
} catch (error) {
178178
vscode.window.showErrorMessage(
@@ -181,11 +181,6 @@ export class Commands {
181181
}
182182
}
183183

184-
private async openFile(filePath: string): Promise<void> {
185-
const uri = vscode.Uri.file(filePath);
186-
await vscode.window.showTextDocument(uri);
187-
}
188-
189184
/**
190185
* Log out and clear stored credentials, requiring re-authentication on next login.
191186
*/
@@ -768,3 +763,22 @@ export class Commands {
768763
});
769764
}
770765
}
766+
767+
async function openFile(filePath: string): Promise<void> {
768+
const uri = vscode.Uri.file(filePath);
769+
await vscode.window.showTextDocument(uri);
770+
}
771+
772+
/**
773+
* Read a directory's entries, returning an empty array if it does not exist.
774+
*/
775+
async function readdirOrEmpty(dirPath: string): Promise<string[]> {
776+
try {
777+
return await fs.readdir(dirPath);
778+
} catch (err) {
779+
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
780+
return [];
781+
}
782+
throw err;
783+
}
784+
}

0 commit comments

Comments
 (0)