Skip to content

Commit

Permalink
Use proto EngineEvents for engine internals
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Jan 9, 2025
1 parent 6913a18 commit c898162
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 436 deletions.
13 changes: 2 additions & 11 deletions frontend/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ provides support for

3. Open any FTL project with a `ftl-project.toml` or `ftl.toml` file.

4. The extension will prompt to start the FTL development server.

## Settings

Configure the FTL extension by setting the following options in your Visual Studio Code settings.json:
Expand All @@ -33,17 +31,10 @@ Configure the FTL extension by setting the following options in your Visual Stud
}
```

- `ftl.devCommandFlags`: Defines flags to pass to the FTL executable when starting the development environment.

```json
{
"ftl.devCommandFlags": ["--parallelism=4"]
}
```
- `ftl.lspCommandFlags`: Defines flags to pass to the FTL executable when starting the development environment.

- `ftl.automaticallyStartServer`: Controls if and when to automatically start the FTL development server. Available options are "always" and "never". If not set, the extension will prompt to start the server when opening a FTL project.
```json
{
"ftl.automaticallyStartServer": "always"
"ftl.lspCommandFlags": []
}
```
23 changes: 2 additions & 21 deletions frontend/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,17 @@
"type": "string",
"description": "Path to the FTL executable. Leave as 'ftl' to use the system PATH."
},
"ftl.devCommandFlags": {
"ftl.lspCommandFlags": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "Flags to pass to the FTL executable when starting ftl dev"
},
"ftl.automaticallyStartServer": {
"type": "string",
"enum": [
"always",
"never"
],
"default": null,
"description": "Control if and when to automatically start the FTL dev server."
"description": "Flags to pass to the FTL executable when starting ftl lsp"
}
}
},
"commands": [
{
"command": "ftl.restart",
"title": "Restart Service",
"category": "FTL"
},
{
"command": "ftl.stop",
"title": "Stop Service",
"category": "FTL"
},
{
"command": "ftl.showLogs",
"title": "Show Logs",
Expand Down
64 changes: 3 additions & 61 deletions frontend/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ExtensionContext } from 'vscode'

import * as vscode from 'vscode'
import { FTLClient } from './client'
import { MIN_FTL_VERSION, checkMinimumVersion, getFTLVersion, getProjectOrWorkspaceRoot, isFTLRunning, resolveFtlPath } from './config'
import { MIN_FTL_VERSION, checkMinimumVersion, getFTLVersion, getProjectOrWorkspaceRoot, resolveFtlPath } from './config'
import { FTLStatus } from './status'

const extensionId = 'ftl'
Expand All @@ -20,24 +20,12 @@ export const activate = async (context: ExtensionContext) => {

client = new FTLClient(statusBarItem, outputChannel)

const restartCmd = vscode.commands.registerCommand(`${extensionId}.restart`, async () => {
console.log('Restarting FTL client')
await client.stop()
console.log('FTL client stopped')
await startClient(context)
console.log('FTL client started')
})

const stopCmd = vscode.commands.registerCommand(`${extensionId}.stop`, async () => client.stop())

const showLogsCommand = vscode.commands.registerCommand('ftl.showLogs', () => {
outputChannel.show()
})

const showCommands = vscode.commands.registerCommand('ftl.statusItemClicked', () => {
const ftlCommands = [
{ label: 'FTL: Restart Service', command: 'ftl.restart' },
{ label: 'FTL: Stop Service', command: 'ftl.stop' },
{ label: 'FTL: Show Logs', command: 'ftl.showLogs' },
]

Expand All @@ -50,7 +38,7 @@ export const activate = async (context: ExtensionContext) => {

await startClient(context)

context.subscriptions.push(restartCmd, stopCmd, statusBarItem, showCommands, showLogsCommand)
context.subscriptions.push(statusBarItem, showCommands, showLogsCommand)
}

export const deactivate = async () => client.stop()
Expand All @@ -74,52 +62,6 @@ const FTLPreflightCheck = async (ftlPath: string) => {
return true
}

const AUTOMATICALLY_START_SERVER_VAR = 'automaticallyStartServer' as const
const PROMPT_OPTIONS = ['Always', 'Yes', 'No', 'Never'] as const
type PromptOption = (typeof PROMPT_OPTIONS)[number]
type AutoStartOption = 'always' | 'never' | 'prompt'

// const promptStartClient = async (context: vscode.ExtensionContext) => {
// const configuration = vscode.workspace.getConfiguration('ftl')
// outputChannel.appendLine(`FTL configuration: ${JSON.stringify(configuration)}`)
// const automaticallyStartServer = configuration.get<AutoStartOption | undefined>(AUTOMATICALLY_START_SERVER_VAR)

// FTLStatus.ftlStopped(statusBarItem)

// if (automaticallyStartServer === 'always') {
// outputChannel.appendLine('FTL development server automatically started')
// await startClient(context)
// return
// }
// if (automaticallyStartServer === 'never') {
// outputChannel.appendLine(`FTL development server not started ('${AUTOMATICALLY_START_SERVER_VAR}' set to 'never' in workspace settings.json)`)
// return
// }

// vscode.window
// .showInformationMessage('FTL project detected. Would you like to start the FTL development server for this workspace?', ...PROMPT_OPTIONS)
// .then(async (result: PromptOption | undefined) => {
// switch (result) {
// case 'Always':
// configuration.update(AUTOMATICALLY_START_SERVER_VAR, 'always', vscode.ConfigurationTarget.Workspace)
// await startClient(context)
// break
// case 'Yes':
// await startClient(context)
// break
// case 'No':
// outputChannel.appendLine('FTL development server disabled')
// FTLStatus.ftlStopped(statusBarItem)
// break
// case 'Never':
// outputChannel.appendLine('FTL development server set to never auto start')
// configuration.update(AUTOMATICALLY_START_SERVER_VAR, 'never', vscode.ConfigurationTarget.Workspace)
// FTLStatus.ftlStopped(statusBarItem)
// break
// }
// })
// }

const startClient = async (context: ExtensionContext) => {
FTLStatus.ftlStarting(statusBarItem)

Expand All @@ -136,7 +78,7 @@ const startClient = async (context: ExtensionContext) => {
return
}

const userFlags = ftlConfig.get<string[]>('devCommandFlags') ?? []
const userFlags = ftlConfig.get<string[]>('lspCommandFlags') ?? []

const flags = [...userFlags]

Expand Down
Loading

0 comments on commit c898162

Please sign in to comment.