Skip to content

Commit dd1a691

Browse files
committed
Fix restart of WM from IDE. Add config option for log level of LSP server and WM. Migrate to new FineCode version. Initial version of test controller.
1 parent 0e4872d commit dd1a691

5 files changed

Lines changed: 382 additions & 12 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ FineCode for VS Code connects VS Code to your FineCode workspace so diagnostics,
88
- Code formatting
99
- Code actions / quick fixes from FineCode handlers
1010
- FineCode action explorer in the Activity Bar
11+
- Native VS Code Test Explorer integration (discover and run tests via the Testing panel)
1112

1213
## Requirements
1314

@@ -58,6 +59,33 @@ Controls when extension notifications are shown:
5859
- `onWarning`
5960
- `always`
6061

62+
### `finecode.logLevel`
63+
64+
Log level for the FineCode LSP server and Workspace Manager server:
65+
66+
- `TRACE`
67+
- `DEBUG`
68+
- `INFO` (default)
69+
- `WARNING`
70+
- `ERROR`
71+
72+
## Testing
73+
74+
The extension integrates with VS Code's native Testing panel (the beaker icon in the Activity Bar).
75+
76+
### Setup
77+
78+
See the FineCode docs for the current testing integration setup steps:
79+
80+
- <https://finecode-dev.github.io/getting-started-ide-mcp/#testing-integration>
81+
82+
### Usage
83+
84+
- Open the **Testing** panel — tests are discovered automatically when the workspace loads.
85+
- Click **Run** next to any test, class, or file to run that scope.
86+
- Failed tests show inline error messages with file and line location.
87+
- The test tree mirrors your project structure: file → class → function.
88+
6189
## Troubleshooting
6290

6391
### No `dev_workspace` found

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@
5454
],
5555
"scope": "machine",
5656
"type": "string"
57+
},
58+
"finecode.logLevel": {
59+
"default": "INFO",
60+
"description": "Log level for the FineCode LSP server and Workspace Manager server.",
61+
"enum": [
62+
"TRACE",
63+
"DEBUG",
64+
"INFO",
65+
"WARNING",
66+
"ERROR"
67+
],
68+
"scope": "machine",
69+
"type": "string"
5770
}
5871
}
5972
},

src/extension.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fs from 'node:fs';
99
import { FineCodeActionsProvider, ActionTreeNode, FinecodeGetActionsResponse } from "./action-tree-provider";
1010
import { createOutputChannel } from './logging';
1111
import * as lsProtocol from "vscode-languageserver-protocol";
12+
import { createTestController } from "./test-controller";
1213

1314

1415
let lsClient: LanguageClient | undefined;
@@ -77,12 +78,14 @@ export async function activate(context: vscode.ExtensionContext) {
7778
outputChannel.info('Starting workspace manager...');
7879
await runWorkspaceManager(outputChannel, actionsProvider);
7980

81+
createTestController(context, getLSClient);
82+
8083
outputChannel.info('Registering commands and providers...');
8184
context.subscriptions.push(
8285
vscode.window.registerTreeDataProvider("fineCodeActions", actionsProvider),
8386
vscode.commands.registerCommand('finecode.restartWorkspaceManager', async () => {
8487
outputChannel.info('Restarting workspace manager');
85-
stopWorkspaceManager();
88+
await stopWorkspaceManager();
8689
runWorkspaceManager(outputChannel, actionsProvider);
8790
}),
8891
vscode.commands.registerCommand("finecode.refreshActions", () =>
@@ -143,7 +146,7 @@ export async function activate(context: vscode.ExtensionContext) {
143146
}
144147

145148
export async function deactivate() {
146-
await stopWorkspaceManager();
149+
await disconnectFromWorkspaceManager();
147150
}
148151

149152
const runWorkspaceManager = async (outputChannel: vscode.LogOutputChannel, actionsProvider: FineCodeActionsProvider) => {
@@ -177,20 +180,14 @@ const runWorkspaceManager = async (outputChannel: vscode.LogOutputChannel, actio
177180
}
178181

179182
const finecodeCmdSplit = (devWorkspacePythonPath as string).split(' ');
180-
const wmArgs = ['start-api', '--trace'];
183+
const logLevel = vscode.workspace.getConfiguration('finecode').get<string>('logLevel', 'INFO');
184+
const wmArgs = ['start-lsp', `--log-level=${logLevel}`];
181185
if (process.env.FINECODE_DEBUG) {
182186
wmArgs.push('--debug');
183187
}
184188
const serverOptions: ServerOptions = {
185189
command: finecodeCmdSplit[0],
186190
args: [...finecodeCmdSplit.slice(1), '-m', 'finecode.cli', ...wmArgs],
187-
// detach from IDE to provide enough time after shutdown to gracefully exit
188-
// and avoid not stopped running processes. Workspace Manager is responsible to
189-
// exit the process as soon in possible after shutdown signal in any case.
190-
//
191-
// detached doesn't work as expected:
192-
// https://github.com/microsoft/vscode-languageserver-node/issues/1595
193-
// temporary detach extension runners instead of workspace manager
194191
options: { cwd: wsDir, detached: false, shell: false },
195192
transport: TransportKind.stdio
196193
};
@@ -262,8 +259,20 @@ const runWorkspaceManager = async (outputChannel: vscode.LogOutputChannel, actio
262259
};
263260

264261

262+
const disconnectFromWorkspaceManager = async () => {
263+
if (lsClient) {
264+
await lsClient.stop();
265+
lsClient = undefined;
266+
}
267+
};
268+
265269
const stopWorkspaceManager = async () => {
266270
if (lsClient) {
271+
try {
272+
await lsClient.sendRequest('server/shutdown', {});
273+
} catch (error) {
274+
console.log('Error sending shutdown request to language server:', error);
275+
}
267276
await lsClient.stop();
268277
lsClient = undefined;
269278
}

0 commit comments

Comments
 (0)